asp身份证验证代码函数

2018-09-06 10:59

阅读:541

  身份证验证代码函数

FunctionCheckCardId(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,,)

IfLen(e)<15OrLen(e)=16OrLen(e)=17OrLen(e)>18Then
CheckCardId=身份证号共有15码或18位
CheckCardId=False
ExitFunction
EndIf

DimAi
IfLen(e)=18Then
Ai=Mid(e,1,17)
ElseIfLen(e)=15Then
Ai=e
Ai=Left(Ai,6)&19&Mid(Ai,7,9)
EndIf
IfNotIsNumeric(Ai)Then
CheckCardId=身份证除最后一位外,必须为数字!

ExitFunction
EndIf
DimstrYear,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)
IfIsDate(BirthDay)Then
IfDateDiff(yyyy,Now,BirthDay)<-140orcdate(BirthDay)>date()Then

CheckCardId=身份证输入错误!

ExitFunction
EndIf
IfstrMonth>12OrstrDay>31Then
CheckCardId=身份证输入错误!

ExitFunction
EndIf
Else
CheckCardId=身份证输入错误!

ExitFunction
EndIf
Dimi,TotalmulAiWi
Fori=0To16
TotalmulAiWi=TotalmulAiWi+CInt(Mid(Ai,i+1,1))*Wi(i)
Next
DimmodValue
modValue=TotalmulAiWiMod11
DimstrVerifyCode
strVerifyCode=arrVerifyCode(modValue)
Ai=Ai&strVerifyCode
CheckCardId=Ai

IfLen(e)=18Ande<>AiThen
CheckCardId=身份证号码输入错误!
ExitFunction
EndIf
EndFunction

response.writeCheckCardId(528337194801020025)这个不知是谁的身份证,我一试就出来了~~~~~~~~~哈哈


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




评论


亲,登录后才可以留言!