Bill: jquery check China ID number

Source: Internet
Author: User
Tags modulus

Mainland 18 ID Card (second-generation ID card)

Identity number is a set of feature combination code, consisting of 17-bit digital body code and a check code.

The sorting order is from left to right: six-digit area code, eight-digit birthday code, three-digit sequence code, and one digit check code.

Check method:

(1) The first 17 digits of the right sum

S = Sum (Ci * Vi), i = 0, ..., 16

Ci: Numeric value indicating position I on ID number

Vi: denotes "weighted factor" at position I
Weighting Factor Vi:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2

(2) Computational modulus (fixed algorithm)

Y = mod (S, 11)

(3) The calculation module y and the corresponding check code check
Y:0 1 2 3 4 5 6 7 8 9 10 (through Y to obtain the corresponding check code and identity card 18th digit check)
Check code: 1 0 X 9 8 7 6 5 4 3 2

functioncheck_id (value) {varArrexp = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];//weighting Factor    varArrvalid = [1, 0, "X", 9, 8, 7, 6, 5, 4, 3, 2];//Check Code    if(/^\d{17}\d|x$/i.test (value)) {           varsum = 0, IDX;  for(vari = 0; i < value.length-1; i++){              //sum the first 17 digits with the weight value productSum + = parseint (Value.substr (i, 1), 10) *Arrexp[i]; }          //computational modulus (fixed algorithm)IDX = sum% 11; //Check whether the 18th is equal to the check code        returnARRVALID[IDX] = = Value.substr (17, 1). toUpperCase (); }Else{          return false; }  }

Bill: jquery check China ID 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.