Javascript second-generation ID card number verification mechanism code _ javascript skills

Source: Internet
Author: User
At the time of registration on A Shanda website, the ID card is required, but I do not want to fill in the real ID card number, so I randomly compiled a string of ID card numbers that I think are legal, however, the system was immediately notified of a number error. Because of the extremely fast response speed, the online verification is not correct. That is to say, the second-generation ID card contains only a few rules that indicate birthday and gender, there are also other self-validation rules. 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.

The 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.
}

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.