JavaScript ID number Effective verification detailed and example code _JAVASCRIPT skills

Source: Internet
Author: User
Tags gettext

Recently need to verify the legitimacy of the ID card, real-name verification is not expected, but the original validation rules too simple, but simply verified the length of the ID card, now the business needs to strengthen the identity card verification rules, the Internet found a lot of information, but not to my mind, helpless had to write directly, Code or with your own comfort ha

JavaScript Authentication ID Number

<%@ page language= "java" contenttype= "text/html; charset=gb18030 "pageencoding=" GB18030 "%> <!
DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >  

According to the online identity card calculation formula written a verification ID number JS

The first step is to multiply the 1th digit of the ID card number with 7, multiply the 2nd digit of the ID number with 9, multiply the 3rd digit of the ID number and 10, multiply the 4th digits of the ID number with 5, and multiply the 5th digits of the ID number with 8. ; multiply the 6th digit of the ID card number with 4; multiply the 7th digit of the ID card number with 2, multiply the 8th digit of the ID number and 1, multiply the 9th digit of the ID number and 6, multiply the 10th digits of the ID number with 3, and multiply the 11th digits of the ID number by 7 ; multiply the 12th digit of the ID card number with 9; multiply the 13th digit of the ID card number with 10, multiply the 14th digit of the ID number and 5, multiply the 15th digit of the ID number with 8, multiply the 16th digits of the ID number with 4, and multiply the 17th digits of the ID number with 2.

The second step: The first step of the ID number 1~17 phase multiplication of the results of the sum, all add up.

Step Three: the result calculated in the second step is divided by 11, in this way, the remainder is 0, the remainder is 1, the remainder is 2, the remainder is 3, the remainder is 4, the remainder is 5, the remainder is 6, the remainder is 7, the remainder is 8, the remainder is 9, and the remainder is 10, a total of 11 possibilities.

Fourth Step: If the remainder is 0, the corresponding last ID number is 1; if the remainder is 1, the corresponding last ID number is 0; if the remainder is 2, the number of the corresponding last ID card is x; If the remainder is 3, the number of the corresponding last ID card is 9. If the remainder is 4, the number of the corresponding last ID card is 8; If the remainder is 5, then the corresponding last ID number is 7; If the remainder is 6, the number of the corresponding last ID card is 6; If the remainder is 7, the number of the corresponding last ID card is 5; If the remainder is 8, The corresponding last ID number is 4; If the remainder is 9, the corresponding last ID number is 3; If the remainder is 10, the number of the corresponding last ID card is 2.

Thank you for reading, I hope to help you, thank you for your support for this site!

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.