JavaScript的身份证验证,出现错误。
代码如下:我一点提交,总是“输入的不是数字”,我填写正确的身份证号码,还是“输入的不是数字” <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
<SCRIPT language=JavaScript>
<!--
//--身份证号码验证-支持新的带x身份证
function isIdCardNo(num)
{
if (isNaN(num)) {alert("输入的不是数字!"); return false;}
var len = num.length, re;
if (len == 15)
re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);
else if (len == 18)
re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\d)$/);
else {alert("输入的数字位数不对!"); return false;}
var a = num.match(re);
if (a != null)
{
if (len==15)
{
var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);
var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
}
else
{
var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);
var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
}
if (!B) {alert("输入的身份证号 "+ a[0] +" 里出生日期不对!"); return false;}
}
return true;
}
//-->
</SCRIPT>
</head>
<body>
<form id="form1" name="form1" method="post" action="shenfengzheng.asp" onSubmit="return isIdCardNo(this)">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <label>
<input NAME="num" class="input_button" value="">
<input type="submit" name="Submit" value="提交" />
</label> </td>
</tr>
</table>
</form>
</body>
</html>
请详细点,麻烦各位了,先谢谢,有分我一定给,我新手,没有分。