ID card verification code Function
Function CheckCardId (e)
ArrVerifyCode = Split (", 0, x, 9, 8 ",",")
Wi = Split ",",")
Checker = Split (", 1 ",",")
If Len (e) <15 Or Len (e) = 16 Or Len (e) = 17 Or Len (e)> 18 Then
CheckCardId = "ID card No. consists of 15 or 18 digits"
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 = "the last digit of the ID card must be a number! "
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 = "Incorrect ID card! "
Exit Function
End If
If strMonth> 12 Or strDay> 31 Then
CheckCardId = "Incorrect ID card! "
Exit Function
End If
Else
CheckCardId = "Incorrect ID card! "
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 = "Incorrect ID number! "
Exit Function
End If
End Function
Response. write CheckCardId ("528337194801020025") ''' I don't know who the ID card is ~~~~~~~~~ Haha
''' If the returned ID card is entered, it indicates that it is correct. Otherwise, an error will be prompted...