function idcheck(e)
idcheck = true
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
'idcheck= "身份證號共有 15 碼或18位"
idcheck = 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
'idcheck= "身份證除最後一位外,必須為數字!"
idcheck = false
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
'idcheck= "身份證輸入錯誤!"
idcheck = false
exit function
end if
if strmonth > 12 or strday > 31 then
idcheck = false
'idcheck= "身份證輸入錯誤!"
exit function
end if
else
'idcheck= "身份證輸入錯誤!"
idcheck = false
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
idcheck = ai
if len(e) = 18 and e <> ai then
'idcheck= "身份證號碼輸入錯誤!"
idcheck = false
exit function
end if
end function
身份證驗證
1 簡單的正規表示式 1 preg match d d dx id card 2 preg match d 18 19 20 d 01 d 0123 d d d x id card 3 preg match d d d x x id card 2 複雜並且嚴格一些的驗證 這個可以驗證15位和18位的...
身份證驗證
身份證分為兩類 1 全是數字 15位或者18位。2 大寫x 18位,最後一位字母x,其餘必需是數字。正則 d d d d x 身份驗證例項 header content type text html charset utf 8 idc post idc bm substr idc,0,6 gende...
身份證驗證JS
function checkidcardstrict idcard var idcard idcard.touppercase var y,jym var s,m var idcard array new array element val idcard idcard array idcard.sp...
身份證驗證指令碼
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...
身份證驗證指令碼
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...