欢迎光临
我们一直在努力

ASP的身份证验证代码改进-ASP教程,ASP应用

建站超值云服务器,限时71元/月

function checkcardid(e)

—————————————

作者:胡建成 email:hjc9246@21cn.com

如输入15位身份证号可产生18位带校检号的身份证号。

如输入的假号,则返回出错提示,大家顶

共享给大家耶

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") 这个不知是谁的身份证,我一试就出来了~~~~~~~~~哈哈

这个如果返回的是输入的身份证,则表明正确,否则会提示出错…

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP的身份证验证代码改进-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章