asp身份证验证代码函数
程序员文章站
2022-05-18 11:44:14
身份证验证代码函数 function checkcardid(e) arrverifycode = split("1,0,x,9,8,7,6,...
身份证验证代码函数
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
response.write checkcardid("528337194801020025") '''''''''这个不知是谁的身份证,我一试就出来了~~~~~~~~~哈哈
'''''这个如果返回的是输入的身份证,则表明正确,否则会提示出错...
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
response.write checkcardid("528337194801020025") '''''''''这个不知是谁的身份证,我一试就出来了~~~~~~~~~哈哈
'''''这个如果返回的是输入的身份证,则表明正确,否则会提示出错...