<script type="text/javascript">
function check(){
reserveTimeId=document.getElementById("reserveTimeId");
if(reserveTimeId.value==null || reserveTimeId.value.length==0){
alert("请选择预约时间!!");
reserveTimeId.value="";
reserveTimeId.focus();
return false;
}
numbersId=document.getElementById("numbersId").value;
if(numbersId==null || numbersId.length==0){
alert("到店人数不能为空!!");
//skuid.focus();
return false;
}
var pattern= /^\d+$/;
if(!pattern.test(numbersId)){
alert("到店人数必须为数字!!");
//skuid.focus();
return false;
}
contactssId=document.getElementById("contactssId");
if(contactssId.value==null || contactssId.value.length==0){
alert("请填写联系人信息!!");
contactssId.value="";
contactssId.focus();
return false;
}
phonesId=document.getElementById("phonesId").value;
if(phonesId==null || phonesId.length==0){
alert("手机号码不能为空!!");
//skuid.focus();
return false;
}
var partten = /^1[3,5,8]\d{9}$/;
var fl=false;
if(!partten.test(phonesId))
{
alert("手机号码格式不对!");
return false;
}
expId=document.getElementById("expId");
if(expId.value==null || expId.value.length==0){
alert("请填写说明!!");
return false;
}
toShopTimeId=document.getElementById("toShopTimeId");
if(toShopTimeId.value==null || toShopTimeId.value.length==0){
alert("请选择到店时间!!");
toShopTimeId.value="";
toShopTimeId.focus();
return false;
}
var remarksId=document.getElementById("remarksId").value.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+$)/g, "");
if(remarksId==""){
alert("请填写备注");
return false;
}
}
</script>
原文:http://blog.csdn.net/wuzhiweiwuzhiwei/article/details/44622435