Detailed description of JavaScript ID card number validation and instance code, and detailed description of javascript

Source: Internet
Author: User

Detailed description of JavaScript ID card number validation and instance code, and detailed description of javascript

Recently, you need to verify the validity of your ID card. real-name verification is not expected. However, the original verification rules are too simple, but they simply verify the length of your ID card, now the business needs to strengthen the identity card verification rules. I found a lot of information on the Internet, but it is not just me, but I have to write one directly, the code is still comfortable with myself.

JavaScript verification ID card 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"> 

A JavaScript code that verifies the ID card number based on the calculation formula of the online id card

Step 1:Multiply the 1st-digit number of the ID card number by 7, the 2nd-digit number of the ID card number by 9, and the 3rd-digit number of the ID card number by 10; multiply the 4th-digit number of the ID card number by 5, the 5th-digit number of the ID card number by 8, and the 6th-digit number of the ID card number by 4; multiply the 7th-digit number of the ID card number by 2, the 8th-digit number of the ID card number by 1, and the 9th-digit number of the ID card number by 6; multiply the 10th-digit number of the ID card number by 3, the 11th-digit number of the ID card number by 7, and the 12th-digit number of the ID card number by 9; multiply the 13th-digit number of the ID card number by 10, the 14th-digit number of the ID card number by 5, and the 15th-digit number of the ID card number by 8; multiply the 16th-digit number of the ID card number by 4, and the 17th-digit number of the ID card number by 2.

Step 2:Set the ID number of step 1 ~ The sum of the result of the 17-digit multiplication, all of which add up.

Step 3:Divide the result calculated in step 2 by 11, so that the remainder is 0, the remainder is 1, the remainder is 2, the remainder is 3, the remainder is 4, and 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.

Step 4:If the remainder is 0, the number of the last ID card is 1. If the remainder is 1, the number of the last ID card is 0. If the remainder is 2, the number of the last ID card is X. If the remainder is 3, the number of the last ID card is 9. If the remainder is 4, the number of the last ID card is 8. If the remainder is 5, the number of the last ID card is 7. If the remainder is 6, the number of the last ID card is 6. If the remainder is 7, the number of the last ID card is 5. If the remainder is 8, the number of the last ID card is 4. If the remainder is 9, the number of the last ID card is 3. If the remainder is 10, the number of the last ID card is 2.

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

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.