指令碼一
if (isnan(document.form1.useridcard.value))
if (document.form1.useridcard.value.length==15) )()?(/d)(/d)(/d)(/d)$/);
var a = num.match(re);
if (a != null)
if (!b)
} else if (document.form1.useridcard.value.length==18) )()?(/d)(/d)(/d)(/d)(/d)$/);
var a = num.match(re);
if (a != null)
if (!b)
}else
指令碼二var rstcard=checkidcard(document.form1.useridcard.value);
if(rstcard!="ok")
function checkidcard(idcard)
var idcard,y,jym;
var s,m;
var idcard_array = new array();
idcard_array = idcard.split("");
//地區檢驗
if(area[parseint(idcard.substr(0,2))]==null) return errors[4];
//身份號碼位數及格式檢驗
switch(idcard.length)[0-9]((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]$/;//測試出生日期的合法性
} else [0-9]((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]$/;//測試出生日期的合法性
}if(ereg.test(idcard))
else
case 18:
//18位身份號碼檢測
//出生日期的合法性檢查
//閏年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
//平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
if ( parseint(idcard.substr(6,4)) % 4 == 0 || (parseint(idcard.substr(6,4)) % 100 == 0 && parseint(idcard.substr(6,4))%4 == 0 ))19[0-9]((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9][0-9xx]$/;//閏年出生日期的合法性正規表示式
} else 19[0-9]((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9][0-9xx]$/;//平年出生日期的合法性正規表示式
}if(ereg.test(idcard))
else return errors[2];
break;
default:
return errors[1];
break;
}函式一
function checkcardid(e)
arrverifycode = split("1,0,x,9,8,7,6,5,4,3,2", ",")
wi = split("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2", ",")
checker = split("1,9,8,7,6,5,4,3,2,1,1", ",")
if len(e) < 15 or len(e) = 16 or len(e) = 17 or len(e) > 18 then
checkcardid= "身份證號共有 15 碼或18位"
checkcardid = false
exit function
end if
dim ai
if len(e) = 18 then
ai = mid(e, 1, 17)
elseif len(e) = 15 then
ai = e
ai = left(ai, 6) & "19" & mid(ai, 7, 9)
end if
if not isnumeric(ai) then
checkcardid= "身份證除最後一位外,必須為數字!"
exit function
end if
dim stryear, strmonth, strday
stryear = cint(mid(ai, 7, 4))
strmonth = cint(mid(ai, 11, 2))
strday = cint(mid(ai, 13, 2))
birthday = trim(stryear) + "-" + trim(strmonth) + "-" + trim(strday)
if isdate(birthday) then
if datediff("yyyy",now,birthday) <-140 or cdate(birthday)> date() then
checkcardid= "身份證輸入錯誤!"
exit function
end if
if strmonth > 12 or strday > 31 then
checkcardid= "身份證輸入錯誤!"
exit function
end if
else
checkcardid= "身份證輸入錯誤!"
exit function
end if
dim i, totalmulaiwi
for i = 0 to 16
totalmulaiwi = totalmulaiwi + cint(mid(ai, i + 1, 1)) * wi(i)
next
dim modvalue
modvalue = totalmulaiwi mod 11
dim strverifycode
strverifycode = arrverifycode(modvalue)
ai = ai & strverifycode
checkcardid = ai
if len(e) = 18 and e <> ai then
checkcardid= "身份證號碼輸入錯誤!"
exit function
end if
end function
身份證號碼驗證
說明 驗證身份證的有效性 引數 cid 身份證號碼 返回 地方 出生時間 性別 private string checkcidinfo string cid if cid.length 18 char c cid cid.length 1 bool last false if c 0 c 9 c a...
驗證身份證號碼
好久沒更新了,今天簽到啦。感覺這個驗證挺重要的,也挺常用的,所以分享給需要的朋友。驗證身份證號碼,在網上找到的好東東 function checkidcard idcard var idcard,y,jym var s,m var idcard array new array idcard arra...
驗證身份證號碼
var idcardnoutil powers 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 paritybit 1 0 x 9 8 7 6 5 4 3 2 genders checkaddresscode function addresscode test address...