Code for verifying the Second Generation ID card number of js
Source: Internet
Author: User
Because the response speed is extremely fast, it is certainly not the correctness of online verification. That is to say, the second-generation ID card has other self-verification rules besides the rules that everyone knows about birthday and gender. So I opened the page source code and found that this section of js was not compressed, so the rules are quite understandable.
I am here to give you some tips. I don't know if it's Mars.
The following code is from here, and copyright belongs to Shanda. Of course, you can also find more detailed introductions and Algorithms in Wikipedia.
Copy codeThe Code is as follows: iW = new Array );
ISum = 0;
For (I = 0; I <17; I ++ ){
IC = v_card.charAt (I );
IVal = parseInt (iC );
ISum + = iVal * iW [I];
}
IJYM = iSum % 11;
Var sJYM = '';
If (iJYM = 0) sJYM = "1 ";
Else if (iJYM = 1) sJYM = "0 ";
Else if (iJYM = 2) sJYM = "x ";
Else if (iJYM = 3) sJYM = "9 ";
Else if (iJYM = 4) sJYM = "8 ";
Else if (iJYM = 5) sJYM = "7 ";
Else if (iJYM = 6) sJYM = "6 ";
Else if (iJYM = 7) sJYM = "5 ";
Else if (iJYM = 8) sJYM = "4 ";
Else if (iJYM = 9) sJYM = "3 ";
Else if (iJYM = 10) sJYM = "2 ";
Var cCheck = v_card.charAt (17). toLowerCase ();
If (cCheck! = SJYM ){
Return false; // a false number is not displayed.
}
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.