CSS
form{
margin-left: 10px;
margin-right: 10px;
}
p{
width: auto;
height: 40px;
padding-top: 10px;
}
p input{
position: absolute;
left: 27%;
width: 70%;
height: 40px;
}
#submit{
margin-top: 10px;
width: 100%;
height: 40px;
color: #FFFFFF;
background-color: #0099CC;
border: 0;
}
span{
color: #FF0000;
}
DIV
<form onsubmit="return gosubmit()" name="frm">
<p><span>*</span>姓名:
<input type='text' id='idAddName' name="addrname" placeholder="请输入收货人姓名">
</p>
<p><span>*</span>电话:
<input type='text' id='idAddPhone' name="addrphone" placeholder="请输入收货人电话">
</p>
<p><span>*</span>省市区:
<input type='text' id='idAddCity' name="addrcity" value="<?php echo $_SESSION['getAddress'] ?>" placeholder="地图定位">
</p>
<p><span>*</span>详细地址:
<input type='text' id='idAddDetail' name="addrdetail" placeholder="街道 小区 门牌号等">
</p>
<input type='submit' id="submit" value='保 存'>
</form>
JS
function gosubmit(){
var valName = document.getElementById('idAddName').value;
var valPhone = document.getElementById('idAddPhone').value;
var valCity = document.getElementById('idAddCity').value;
var valDetail = document.getElementById('idAddDetail').value;
if((valName == '')
||(valPhone == '')
||(valCity == '')
||(valDetail == '')){
alert('请填写完整的信息!');
return false;
}else{
document.frm.action= "address.php?";
document.frm.method='get';
document.frm.submit();
return true;
}
}
一些扩展阅读:
http://www.oschina.net/code/snippet_216459_11382
http://blog.csdn.net/wanghuan203/article/details/7220540