ID card verification code function
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="The ID number has 15 codes or 18 digits in total"
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="Except the last digit, the ID card must be a number!"
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="Identity card entered incorrectly!"
ExitFunction
EndIf
IfstrMonth>12OrstrDay>31Then
CheckCardId="Identity card entered incorrectly!"
ExitFunction
EndIf
Else
CheckCardId="Identity card entered incorrectly!"
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="Identity card number entered incorrectly!"
ExitFunction
EndIf
EndFunction
response.writeCheckCardId("528337194801020025")''''''''''''''I don't know whose ID card this is, I tried it out~~~~~~~~~~~~~ Haha
'''''This If the returned ID card is entered, it means it is correct, otherwise an error will be prompted...