<form action="" method="post" onsubmit="return checkForm(this)">
<input id="p_tel" type="text" name="p_tel" />
<input id="p_cardid" type="text" name="p_cardid" />
<button type="submit"> 查询</button>
</form>
function checkForm(){
var phone = document.getElementById('p_tel').value;
var cardid=document.getElementById('p_cardid').value;
if(phone==""&&cardid==""){
alert("请输入手机号和身份证号!");return false;
}else if(phone==""){
alert("请输入手机号!");return false;
}else{
if(!(/^1(3|4|5|7|8)\d{9}$/.test(phone))){
alert("手机号码有误,请重新输入");
return false;
}
if(cardid==""){
alert("请输入身份证号!");return false;
}
}
if(!(/^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/.test(cardid))){
alert("身份证号有误,请重新输入");return false;
}
}