The function of ASP to realize ID card verification

Source: Internet
Author: User
Tags exit end split trim
This is correct if you return the input ID, or you will be prompted for an error

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) < or Len (e) = or Len (e) = or Len (e) > Then
Checkcardid= "ID number is 15 yards or 18 digits."
Checkcardid = False
Exit Function
End If
Dim Ai
If Len (e) = Then
Ai = Mid (E, 1, 17)
ElseIf Len (e) = Then
Ai = E
Ai = Left (AI, 6) & "A" & Mid (AI, 7, 9)
End If
If not IsNumeric (Ai) Then
Checkcardid= "ID card in addition to the last one, 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= "ID card input Error! "
Exit Function
End If
If strmonth > Or strday > Then
Checkcardid= "ID card input Error! "
Exit Function
End If
Else
Checkcardid= "ID card input Error! "
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) = e <> Ai Then
Checkcardid= "ID card number input Error! "
Exit Function
End If
End Function
Response.Write Checkcardid ("528337194801020025") "'



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.