<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns="http://www.w3.org/1999/xhtml "> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script> function defaultagree(){ //验证身份证号 if(!Isidcard(document.updateprofile.idcardnumber.value)) { alert("身份证号码输入有误"); return false; } //验证手机号码 var phone = /^[0-9]*[1-9][0-9]*$/; if(!phone.exec(document.updateprofile.phonenumber.value)) { alert("手机号码输入有误"); return false; } //验证电子邮件 var email =/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/; if(!email.exec(document.updateprofile.email.value)) { alert("电子邮件格式错误"); return false; } var date = /^[1-2]\\d{3}-(0?[1-9]||1[0-2])-(0?[1-9]||[1-2][1-9]||3[0-1])$/; if(!date.exec(document.updateprofile.brithDate.value)) { alert("日期格式错误"); return false; } } //验证身份证号的方法 function Isidcard(num) { var idcard =/\d{17}[xX0-9]{1}|\d{14}[xX0-9]{1}/; return(idcard.test(num)); } </script> </head>
<body> <form name="updateprofile" action="updateprofile" method="post" onSubmit="return defaultagree(this)"> <table> <td>出生日期:</td> <td align="left"><input type="text" name="brithDate" value=""></input><font color="gray" size="2">*日期格式必须为yyyy-mm-dd</font></td> </tr> <tr> <td>身份证号:</td> <td align="left"><input type="text" name="idcardnumber" value=""></input><font color="gray" size="2">*必须为18有效身份证号码</font></td> </tr> <tr> <td>手机号码:</td> <td align="left"><input type="text" name="phonenumber" value=""></input><font color="gray" size="2">*手机号码必须为有效</font></td> </tr> <tr> <td>电子邮件:</td> <td align="left"><input type="text" name="email" value=""></input><font color="gray" size="2">*邮件格式必须为xxx@xx.xx</font > </td> </tr> <tr> <td></td><td align="left"></input><input type="submit" value="保存"></input>
</td> </tr> </table> </form> </body> </html>
2011-03-17 16:46:53