JS second generation ID card number verification mechanism code _JAVASCRIPT skills

Source: Internet
Author: User
Because the response speed is extremely fast, it is certainly not the online checksum correctness, that is to say, the second-generation ID card except for the number of birthdays and genders that everyone knows, there are other rules for self-regulation. So open the page source view, found that this section of JS has not been compressed, so the rules are very understood.
Here to everyone under the popular science, do not know is not Mars, hehe.
The following code comes from here and the copyright is grand. Of course, you can also find a more detailed introduction and algorithm in Wikipedia.
Copy Code code as follows:

IW = new Array (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
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 = ten) Sjym = "2";
var ccheck = V_card.charat. toLowerCase ();
if (Ccheck!= sjym) {
return false;//No, that's fake number
}

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.