Browse Source

#793: Add Chinese citizen ID validator, thanks to @shamiao

phuoc 11 years ago
parent
commit
f7b70b6efa

+ 1 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@ __New Features__
 * [#761](https://github.com/nghuuphuoc/bootstrapvalidator/pull/761): Add Romania postal code validator, thanks to [@adrian-dks](https://github.com/adrian-dks)
 * [#761](https://github.com/nghuuphuoc/bootstrapvalidator/pull/761): Add Romania postal code validator, thanks to [@adrian-dks](https://github.com/adrian-dks)
 * [#785](https://github.com/nghuuphuoc/bootstrapvalidator/pull/785): Add Denmark phone number validator, thanks to [@emilchristensen](https://github.com/emilchristensen)
 * [#785](https://github.com/nghuuphuoc/bootstrapvalidator/pull/785): Add Denmark phone number validator, thanks to [@emilchristensen](https://github.com/emilchristensen)
 * [#787](https://github.com/nghuuphuoc/bootstrapvalidator/pull/787): Add Thailand phone number and ID validator, thanks to [@emilchristensen](https://github.com/emilchristensen)
 * [#787](https://github.com/nghuuphuoc/bootstrapvalidator/pull/787): Add Thailand phone number and ID validator, thanks to [@emilchristensen](https://github.com/emilchristensen)
+* [#793](https://github.com/nghuuphuoc/bootstrapvalidator/pull/793): Add Chinese citizen ID validator, thanks to [@shamiao](https://github.com/shamiao)
 
 
 __Changes__
 __Changes__
 * [#753](https://github.com/nghuuphuoc/bootstrapvalidator/issues/753): Change the default type of [remote](http://bootstrapvalidator.com/validators/remote/) validator to GET
 * [#753](https://github.com/nghuuphuoc/bootstrapvalidator/issues/753): Change the default type of [remote](http://bootstrapvalidator.com/validators/remote/) validator to GET

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
  *
- * @version     v0.5.2-dev, built on 2014-09-06 9:35:49 PM
+ * @version     v0.5.2-dev, built on 2014-09-07 9:59:49 AM
  * @author      https://twitter.com/nghuuphuoc
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
  * @license     MIT

+ 539 - 2
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
  *
- * @version     v0.5.2-dev, built on 2014-09-06 9:35:49 PM
+ * @version     v0.5.2-dev, built on 2014-09-07 9:59:49 AM
  * @author      https://twitter.com/nghuuphuoc
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
  * @license     MIT
@@ -3245,6 +3245,7 @@
             BR: 'Brazil',
             BR: 'Brazil',
             CH: 'Switzerland',
             CH: 'Switzerland',
             CL: 'Chile',
             CL: 'Chile',
+            CN: 'China',
             CZ: 'Czech',
             CZ: 'Czech',
             DK: 'Denmark',
             DK: 'Denmark',
             EE: 'Estonia',
             EE: 'Estonia',
@@ -3277,7 +3278,7 @@
 
 
         // Supported country codes
         // Supported country codes
         COUNTRY_CODES: [
         COUNTRY_CODES: [
-            'BA', 'BG', 'BR', 'CH', 'CL', 'CZ', 'DK', 'EE', 'ES', 'FI', 'HR', 'IE', 'IS', 'LT', 'LV', 'ME', 'MK', 'NL',
+            'BA', 'BG', 'BR', 'CH', 'CL', 'CN', 'CZ', 'DK', 'EE', 'ES', 'FI', 'HR', 'IE', 'IS', 'LT', 'LV', 'ME', 'MK', 'NL',
             'RO', 'RS', 'SE', 'SI', 'SK', 'SM', 'TH', 'ZA'
             'RO', 'RS', 'SE', 'SI', 'SK', 'SM', 'TH', 'ZA'
         ],
         ],
 
 
@@ -3552,6 +3553,542 @@
         },
         },
 
 
         /**
         /**
+         * Validate Chinese citizen identification number
+         *
+         * Rules:
+         * - For current 18-digit system (since 1st Oct 1999, defined by GB11643—1999 national standard):
+         *     - Digit 0-5: Must be a valid administrative division code of China PR.
+         *     - Digit 6-13: Must be a valid YYYYMMDD date of birth. A future date is tolerated.
+         *     - Digit 14-16: Order code, any integer.
+         *     - Digit 17: An ISO 7064:1983, MOD 11-2 checksum.
+         *       Both upper/lower case of X are tolerated.
+         * - For deprecated 15-digit system:
+         *     - Digit 0-5: Must be a valid administrative division code of China PR.
+         *     - Digit 6-11: Must be a valid YYMMDD date of birth, indicating the year of 19XX.
+         *     - Digit 12-14: Order code, any integer.
+         * Lists of valid administrative division codes of China PR can be seen here:
+         * <http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/>
+         * Published and maintained by National Bureau of Statistics of China PR.
+         * NOTE: Current and deprecated codes MUST BOTH be considered valid.
+         * Many Chinese citizens born in once existed administrative divisions!
+         *
+         * @see http://en.wikipedia.org/wiki/Resident_Identity_Card#Identity_card_number
+         * @param {String} value The ID
+         * @returns {Boolean}
+         */
+        _cn: function(value) {
+            // Basic format check (18 or 15 digits, considering X in checksum)
+            value = value.trim();
+            if (!/^\d{15}$/.test(value) && !/^\d{17}[\dXx]{1}$/.test(value)) {
+                return false;
+            }
+            
+            // Check China PR Administrative division code
+            var adminDivisionCodes = {
+                11: {
+                    0: [0],
+                    1: [[0, 9], [11, 17]],
+                    2: [0, [28, 29]]
+                },
+                12: {
+                    0: [0],
+                    1: [[0, 16]],
+                    2: [0, 21, 23, 25]
+                },
+                13: {
+                    0: [0],
+                    1: [[0, 5], [7, 8], 21, [23, 33], [81, 85]],
+                    2: [[0, 5], [7, 9], [23, 25], 27, [29, 30], 81, 83],
+                    3: [[0, 4], [21, 24]],
+                    4: [[0, 4], 6, 21, [23, 35], 81],
+                    5: [[0, 3], [21, 35], [81, 82]],
+                    6: [[0, 4], [21, 38], [81, 84]],
+                    7: [[0, 3], [5, 6], [21, 33]],
+                    8: [[0, 4], [21, 28]],
+                    9: [[0, 3], [21, 30], [81, 84]],
+                    10: [[0, 3], [22, 26], 28, [81, 82]],
+                    11: [[0, 2], [21, 28], [81, 82]]
+                },
+                14: {
+                    0: [0],
+                    1: [[0, 1], [5, 10], [21, 23], 81],
+                    2: [[0, 3], [11, 12], [21, 27]],
+                    3: [[0, 3], 11, [21, 22]],
+                    4: [[0, 2], 11, 21, [23, 31], 81],
+                    5: [[0, 2], [21, 22], [24, 25], 81],
+                    6: [[0, 3], [21, 24]],
+                    7: [[0, 2], [21, 29], 81],
+                    8: [[0, 2], [21, 30], [81, 82]],
+                    9: [[0, 2], [21, 32], 81],
+                    10: [[0, 2], [21, 34], [81, 82]],
+                    11: [[0, 2], [21, 30], [81, 82]],
+                    23: [[0, 3], [22, 23], [25, 30], [32, 33]]
+                },
+                15: {
+                    0: [0],
+                    1: [[0, 5], [21, 25]],
+                    2: [[0, 7], [21, 23]],
+                    3: [[0, 4]],
+                    4: [[0, 4], [21, 26], [28, 30]],
+                    5: [[0, 2], [21, 26], 81],
+                    6: [[0, 2], [21, 27]],
+                    7: [[0, 3], [21, 27], [81, 85]],
+                    8: [[0, 2], [21, 26]],
+                    9: [[0, 2], [21, 29], 81],
+                    22: [[0, 2], [21, 24]],
+                    25: [[0, 2], [22, 31]],
+                    26: [[0, 2], [24, 27], [29, 32], 34],
+                    28: [[0, 1], [22, 27]],
+                    29: [0, [21, 23]]
+                },
+                21: {
+                    0: [0],
+                    1: [[0, 6], [11, 14], [22, 24], 81],
+                    2: [[0, 4], [11, 13], 24, [81, 83]],
+                    3: [[0, 4], 11, 21, 23, 81],
+                    4: [[0, 4], 11, [21, 23]],
+                    5: [[0, 5], [21, 22]],
+                    6: [[0, 4], 24, [81, 82]],
+                    7: [[0, 3], 11, [26, 27], [81, 82]],
+                    8: [[0, 4], 11, [81, 82]],
+                    9: [[0, 5], 11, [21, 22]],
+                    10: [[0, 5], 11, 21, 81],
+                    11: [[0, 3], [21, 22]],
+                    12: [[0, 2], 4, 21, [23, 24], [81, 82]],
+                    13: [[0, 3], [21, 22], 24, [81, 82]],
+                    14: [[0, 4], [21, 22], 81]
+                },
+                22: {
+                    0: [0],
+                    1: [[0, 6], 12, 22, [81, 83]],
+                    2: [[0, 4], 11, 21, [81, 84]],
+                    3: [[0, 3], [22, 23], [81, 82]],
+                    4: [[0, 3], [21, 22]],
+                    5: [[0, 3], 21, [23, 24], [81, 82]],
+                    6: [[0, 2], [4, 5], [21, 23], 25, 81],
+                    7: [[0, 2], [21, 24], 81],
+                    8: [[0, 2], [21, 22], [81, 82]],
+                    24: [[0, 6], 24, 26]
+                },
+                23: {
+                    0: [0],
+                    1: [[0, 12], 21, [23, 29], [81, 84]],
+                    2: [[0, 8], 21, [23, 25], 27, [29, 31], 81],
+                    3: [[0, 7], 21, [81, 82]],
+                    4: [[0, 7], [21, 22]],
+                    5: [[0, 3], [5, 6], [21, 24]],
+                    6: [[0, 6], [21, 24]],
+                    7: [[0, 16], 22, 81],
+                    8: [[0, 5], 11, 22, 26, 28, 33, [81, 82]],
+                    9: [[0, 4], 21],
+                    10: [[0, 5], [24, 25], 81, [83, 85]],
+                    11: [[0, 2], 21, [23, 24], [81, 82]],
+                    12: [[0, 2], [21, 26], [81, 83]],
+                    27: [[0, 4], [21, 23]]
+                },
+                31: {
+                    0: [0],
+                    1: [[0, 1], [3, 10], [12, 20]],
+                    2: [0, 30]
+                },
+                32: {
+                    0: [0],
+                    1: [[0, 7], 11, [13, 18], [24, 25]],
+                    2: [[0, 6], 11, [81, 82]],
+                    3: [[0, 5], [11, 12], [21, 24], [81, 82]],
+                    4: [[0, 2], [4, 5], [11, 12], [81, 82]],
+                    5: [[0, 9], [81, 85]],
+                    6: [[0, 2], [11, 12], 21, 23, [81, 84]],
+                    7: [[0, 1], 3, [5, 6], [21, 24]],
+                    8: [[0, 4], 11, 26, [29, 31]],
+                    9: [[0, 3], [21, 25], 28, [81, 82]],
+                    10: [[0, 3], [11, 12], 23, 81, 84, 88],
+                    11: [[0, 2], [11, 12], [81, 83]],
+                    12: [[0, 4], [81, 84]],
+                    13: [[0, 2], 11, [21, 24]]
+                },
+                33: {
+                    0: [0],
+                    1: [[0, 6], [8, 10], 22, 27, [82, 83], 85],
+                    2: [[0, 1], [3, 6], [11, 12], [25, 26], [81, 83]],
+                    3: [[0, 4], 22, 24, [26, 29], [81, 82]],
+                    4: [[0, 2], 11, 21, 24, [81, 83]],
+                    5: [[0, 3], [21, 23]],
+                    6: [[0, 2], 21, 24, [81, 83]],
+                    7: [[0, 3], 23, [26, 27], [81, 84]],
+                    8: [[0, 3], 22, [24, 25], 81],
+                    9: [[0, 3], [21, 22]],
+                    10: [[0, 4], [21, 24], [81, 82]],
+                    11: [[0, 2], [21, 27], 81]
+                },
+                34: {
+                    0: [0],
+                    1: [[0, 4], 11, [21, 24], 81],
+                    2: [[0, 4], [7, 8], [21, 23], 25],
+                    3: [[0, 4], 11, [21, 23]],
+                    4: [[0, 6], 21],
+                    5: [[0, 4], 6, [21, 23]],
+                    6: [[0, 4], 21],
+                    7: [[0, 3], 11, 21],
+                    8: [[0, 3], 11, [22, 28], 81],
+                    10: [[0, 4], [21, 24]],
+                    11: [[0, 3], 22, [24, 26], [81, 82]],
+                    12: [[0, 4], [21, 22], [25, 26], 82],
+                    13: [[0, 2], [21, 24]],
+                    14: [[0, 2], [21, 24]],
+                    15: [[0, 3], [21, 25]],
+                    16: [[0, 2], [21, 23]],
+                    17: [[0, 2], [21, 23]],
+                    18: [[0, 2], [21, 25], 81]
+                },
+                35: {
+                    0: [0],
+                    1: [[0, 5], 11, [21, 25], 28, [81, 82]],
+                    2: [[0, 6], [11, 13]],
+                    3: [[0, 5], 22],
+                    4: [[0, 3], 21, [23, 30], 81],
+                    5: [[0, 5], 21, [24, 27], [81, 83]],
+                    6: [[0, 3], [22, 29], 81],
+                    7: [[0, 2], [21, 25], [81, 84]],
+                    8: [[0, 2], [21, 25], 81],
+                    9: [[0, 2], [21, 26], [81, 82]]
+                },
+                36: {
+                    0: [0],
+                    1: [[0, 5], 11, [21, 24]],
+                    2: [[0, 3], 22, 81],
+                    3: [[0, 2], 13, [21, 23]],
+                    4: [[0, 3], 21, [23, 30], [81, 82]],
+                    5: [[0, 2], 21],
+                    6: [[0, 2], 22, 81],
+                    7: [[0, 2], [21, 35], [81, 82]],
+                    8: [[0, 3], [21, 30], 81],
+                    9: [[0, 2], [21, 26], [81, 83]],
+                    10: [[0, 2], [21, 30]],
+                    11: [[0, 2], [21, 30], 81]
+                },
+                37: {
+                    0: [0],
+                    1: [[0, 5], [12, 13], [24, 26], 81],
+                    2: [[0, 3], 5, [11, 14], [81, 85]],
+                    3: [[0, 6], [21, 23]],
+                    4: [[0, 6], 81],
+                    5: [[0, 3], [21, 23]],
+                    6: [[0, 2], [11, 13], 34, [81, 87]],
+                    7: [[0, 5], [24, 25], [81, 86]],
+                    8: [[0, 2], 11, [26, 32], [81, 83]],
+                    9: [[0, 3], 11, 21, 23, [82, 83]],
+                    10: [[0, 2], [81, 83]],
+                    11: [[0, 3], [21, 22]],
+                    12: [[0, 3]],
+                    13: [[0, 2], [11, 12], [21, 29]],
+                    14: [[0, 2], [21, 28], [81, 82]],
+                    15: [[0, 2], [21, 26], 81],
+                    16: [[0, 2], [21, 26]],
+                    17: [[0, 2], [21, 28]]
+                },
+                41: {
+                    0: [0],
+                    1: [[0, 6], 8, 22, [81, 85]],
+                    2: [[0, 5], 11, [21, 25]],
+                    3: [[0, 7], 11, [22, 29], 81],
+                    4: [[0, 4], 11, [21, 23], 25, [81, 82]],
+                    5: [[0, 3], [5, 6], [22, 23], [26, 27], 81],
+                    6: [[0, 3], 11, [21, 22]],
+                    7: [[0, 4], 11, 21, [24, 28], [81, 82]],
+                    8: [[0, 4], 11, [21, 23], 25, [81, 83]],
+                    9: [[0, 2], [22, 23], [26, 28]],
+                    10: [[0, 2], [23, 25], [81, 82]],
+                    11: [[0, 4], [21, 23]],
+                    12: [[0, 2], [21, 22], 24, [81, 82]],
+                    13: [[0, 3], [21, 30], 81],
+                    14: [[0, 3], [21, 26], 81],
+                    15: [[0, 3], [21, 28]],
+                    16: [[0, 2], [21, 28], 81],
+                    17: [[0, 2], [21, 29]],
+                    90: [[0, 1]]
+                },
+                42: {
+                    0: [0],
+                    1: [[0, 7], [11, 17]],
+                    2: [[0, 5], 22, 81],
+                    3: [[0, 3], [21, 25], 81],
+                    5: [[0, 6], [25, 29], [81, 83]],
+                    6: [[0, 2], [6, 7], [24, 26], [82, 84]],
+                    7: [[0, 4]],
+                    8: [[0, 2], 4, [21, 22], 81],
+                    9: [[0, 2], [21, 23], [81, 82], 84],
+                    10: [[0, 3], [22, 24], 81, 83, 87],
+                    11: [[0, 2], [21, 27], [81, 82]],
+                    12: [[0, 2], [21, 24], 81],
+                    13: [[0, 3], 21, 81],
+                    28: [[0, 2], [22, 23], [25, 28]],
+                    90: [0, [4, 6], 21]
+                },
+                43: {
+                    0: [0],
+                    1: [[0, 5], [11, 12], [21, 22], 24, 81],
+                    2: [[0, 4], 11, 21, [23, 25], 81],
+                    3: [[0, 2], 4, 21, [81, 82]],
+                    4: [[0, 1], [5, 8], 12, [21, 24], 26, [81, 82]],
+                    5: [[0, 3], 11, [21, 25], [27, 29], 81],
+                    6: [[0, 3], 11, 21, [23, 24], 26, [81, 82]],
+                    7: [[0, 3], [21, 26], 81],
+                    8: [[0, 2], 11, [21, 22]],
+                    9: [[0, 3], [21, 23], 81],
+                    10: [[0, 3], [21, 28], 81],
+                    11: [[0, 3], [21, 29]],
+                    12: [[0, 2], [21, 30], 81],
+                    13: [[0, 2], [21, 22], [81, 82]],
+                    31: [[0, 1], [22, 27], 30]
+                },
+                44: {
+                    0: [0],
+                    1: [[0, 7], [11, 16], [83, 84]],
+                    2: [[0, 5], [21, 22], 24, 29, [32, 33], [81, 82]],
+                    3: [[0, 1], [3, 8]],
+                    4: [[0, 4]],
+                    5: [[0, 1], [6, 15], 23, [82, 83]],
+                    6: [[0, 1], [4, 8]],
+                    7: [[0, 1], [3, 5], 81, [83, 85]],
+                    8: [[0, 4], 11, 23, 25, [81, 83]],
+                    9: [[0, 3], 23, [81, 83]],
+                    12: [[0, 3], [23, 26], [83, 84]],
+                    13: [[0, 3], [22, 24], 81],
+                    14: [[0, 2], [21, 24], [26, 27], 81],
+                    15: [[0, 2], 21, 23, 81],
+                    16: [[0, 2], [21, 25]],
+                    17: [[0, 2], 21, 23, 81],
+                    18: [[0, 3], 21, 23, [25, 27], [81, 82]],
+                    19: [0],
+                    20: [0],
+                    51: [[0, 3], [21, 22]],
+                    52: [[0, 3], [21, 22], 24, 81],
+                    53: [[0, 2], [21, 23], 81]
+                },
+                45: {
+                    0: [0],
+                    1: [[0, 9], [21, 27]],
+                    2: [[0, 5], [21, 26]],
+                    3: [[0, 5], [11, 12], [21, 32]],
+                    4: [[0, 1], [3, 6], 11, [21, 23], 81],
+                    5: [[0, 3], 12, 21],
+                    6: [[0, 3], 21, 81],
+                    7: [[0, 3], [21, 22]],
+                    8: [[0, 4], 21, 81],
+                    9: [[0, 3], [21, 24], 81],
+                    10: [[0, 2], [21, 31]],
+                    11: [[0, 2], [21, 23]],
+                    12: [[0, 2], [21, 29], 81],
+                    13: [[0, 2], [21, 24], 81],
+                    14: [[0, 2], [21, 25], 81]
+                },
+                46: {
+                    0: [0],
+                    1: [[0, 1], [5, 8]],
+                    2: [[0, 1]],
+                    3: [0, [21, 23]],
+                    90: [[0, 3], [5, 7], [21, 39]]
+                },
+                50: {
+                    0: [0],
+                    1: [[0, 19]],
+                    2: [0, [22, 38], [40, 43]],
+                    3: [0, [81, 84]]
+                },
+                51: {
+                    0: [0],
+                    1: [[0, 1], [4, 8], [12, 15], [21, 24], 29, [31, 32], [81, 84]],
+                    3: [[0, 4], 11, [21, 22]],
+                    4: [[0, 3], 11, [21, 22]],
+                    5: [[0, 4], [21, 22], [24, 25]],
+                    6: [[0, 1], 3, 23, 26, [81, 83]],
+                    7: [[0, 1], [3, 4], [22, 27], 81],
+                    8: [[0, 2], [11, 12], [21, 24]],
+                    9: [[0, 4], [21, 23]],
+                    10: [[0, 2], 11, [24, 25], 28],
+                    11: [[0, 2], [11, 13], [23, 24], 26, 29, [32, 33], 81],
+                    13: [[0, 4], [21, 25], 81],
+                    14: [[0, 2], [21, 25]],
+                    15: [[0, 3], [21, 29]],
+                    16: [[0, 3], [21, 23], 81],
+                    17: [[0, 3], [21, 25], 81],
+                    18: [[0, 3], [21, 27]],
+                    19: [[0, 3], [21, 23]],
+                    20: [[0, 2], [21, 22], 81],
+                    32: [0, [21, 33]],
+                    33: [0, [21, 38]],
+                    34: [[0, 1], [22, 37]]
+                },
+                52: {
+                    0: [0],
+                    1: [[0, 3], [11, 15], [21, 23], 81],
+                    2: [[0, 1], 3, [21, 22]],
+                    3: [[0, 3], [21, 30], [81, 82]],
+                    4: [[0, 2], [21, 25]],
+                    5: [[0, 2], [21, 27]],
+                    6: [[0, 3], [21, 28]],
+                    22: [[0, 1], [22, 30]],
+                    23: [[0, 1], [22, 28]],
+                    24: [[0, 1], [22, 28]],
+                    26: [[0, 1], [22, 36]],
+                    27: [[0, 2], [22, 23], [25, 32]]
+                },
+                53: {
+                    0: [0],
+                    1: [[0, 3], [11, 14], [21, 22], [24, 29], 81],
+                    3: [[0, 2], [21, 26], 28, 81],
+                    4: [[0, 2], [21, 28]],
+                    5: [[0, 2], [21, 24]],
+                    6: [[0, 2], [21, 30]],
+                    7: [[0, 2], [21, 24]],
+                    8: [[0, 2], [21, 29]],
+                    9: [[0, 2], [21, 27]],
+                    23: [[0, 1], [22, 29], 31],
+                    25: [[0, 4], [22, 32]],
+                    26: [[0, 1], [21, 28]],
+                    27: [[0, 1], [22, 30]], 28: [[0, 1], [22, 23]],
+                    29: [[0, 1], [22, 32]],
+                    31: [0, [2, 3], [22, 24]],
+                    34: [0, [21, 23]],
+                    33: [0, 21, [23, 25]],
+                    35: [0, [21, 28]]
+                },
+                54: {
+                    0: [0],
+                    1: [[0, 2], [21, 27]],
+                    21: [0, [21, 29], [32, 33]],
+                    22: [0, [21, 29], [31, 33]],
+                    23: [[0, 1], [22, 38]],
+                    24: [0, [21, 31]],
+                    25: [0, [21, 27]],
+                    26: [0, [21, 27]]
+                },
+                61: {
+                    0: [0],
+                    1: [[0, 4], [11, 16], 22, [24, 26]],
+                    2: [[0, 4], 22],
+                    3: [[0, 4], [21, 24], [26, 31]],
+                    4: [[0, 4], [22, 31], 81],
+                    5: [[0, 2], [21, 28], [81, 82]],
+                    6: [[0, 2], [21, 32]],
+                    7: [[0, 2], [21, 30]],
+                    8: [[0, 2], [21, 31]],
+                    9: [[0, 2], [21, 29]],
+                    10: [[0, 2], [21, 26]]
+                },
+                62: {
+                    0: [0],
+                    1: [[0, 5], 11, [21, 23]],
+                    2: [[0, 1]],
+                    3: [[0, 2], 21],
+                    4: [[0, 3], [21, 23]],
+                    5: [[0, 3], [21, 25]],
+                    6: [[0, 2], [21, 23]],
+                    7: [[0, 2], [21, 25]],
+                    8: [[0, 2], [21, 26]],
+                    9: [[0, 2], [21, 24], [81, 82]],
+                    10: [[0, 2], [21, 27]],
+                    11: [[0, 2], [21, 26]],
+                    12: [[0, 2], [21, 28]],
+                    24: [0, 21, [24, 29]],
+                    26: [0, 21, [23, 30]],
+                    29: [[0, 1], [21, 27]],
+                    30: [[0, 1], [21, 27]]
+                },
+                63: {
+                    0: [0],
+                    1: [[0, 5], [21, 23]],
+                    2: [0, 2, [21, 25]],
+                    21: [0, [21, 23], [26, 28]],
+                    22: [0, [21, 24]],
+                    23: [0, [21, 24]],
+                    25: [0, [21, 25]],
+                    26: [0, [21, 26]],
+                    27: [[0, 1], [21, 26]],
+                    28: [[0, 2], [21, 23]]
+                },
+                64: {
+                    0: [0],
+                    1: [[0, 1], [4, 6], [21, 22], 81],
+                    2: [[0, 3], 5, [21, 23]],
+                    3: [[0, 3], [21, 24], 81],
+                    4: [[0, 2], [21, 25]],
+                    5: [[0, 2], [21, 22]]
+                },
+                65: {
+                    0: [0],
+                    1: [[0, 9], 21],
+                    2: [[0, 5]],
+                    21: [[0, 1], [22, 23]],
+                    22: [[0, 1], [22, 23]],
+                    23: [[0, 3], [23, 25], [27, 28]],
+                    28: [[0, 1], [22, 29]],
+                    29: [[0, 1], [22, 29]],
+                    30: [[0, 1], [22, 24]], 31: [[0, 1], [21, 31]],
+                    32: [[0, 1], [21, 27]],
+                    40: [0, [2, 3], [21, 28]],
+                    42: [[0, 2], 21, [23, 26]],
+                    43: [[0, 1], [21, 26]],
+                    90: [[0, 4]], 27: [[0, 2], [22, 23]]
+                },
+                71: { 0: [0] },
+                81: { 0: [0] },
+                82: { 0: [0] }
+            };
+            
+            var provincial  = parseInt(value.substr(0, 2), 10),
+                prefectural = parseInt(value.substr(2, 2), 10),
+                county      = parseInt(value.substr(4, 2), 10);
+            
+            if (!adminDivisionCodes[provincial] || !adminDivisionCodes[provincial][prefectural]) {
+                return false;
+            }
+            var inRange  = false,
+                rangeDef = adminDivisionCodes[provincial][prefectural];
+            for (var i = 0; i < rangeDef.length; i++) {
+                if (($.isArray(rangeDef[i]) && rangeDef[i][0] <= county && county <= rangeDef[i][1])
+                    || (!$.isArray(rangeDef[i]) && county === rangeDef[i]))
+                {
+                    inRange = true;
+                    break;
+                }
+            }
+
+            if (!inRange) {
+                return false;
+            }
+            
+            // Check date of birth
+            var dob;
+            if (value.length === 18) {
+                dob = value.substr(6, 8);
+            } else /* length == 15 */ { 
+                dob = '19' + value.substr(6, 6);
+            }
+            var year  = parseInt(dob.substr(0, 4), 10),
+                month = parseInt(dob.substr(4, 2), 10),
+                day   = parseInt(dob.substr(6, 2), 10);
+            if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) {
+                return false;
+            }
+            
+            // Check checksum (18-digit system only)
+            if (value.length === 18) {
+                var sum    = 0,
+                    weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
+                for (i = 0; i < 17; i++) {
+                    sum += parseInt(value.charAt(i), 10) * weight[i];
+                }
+                sum = (12 - (sum % 11)) % 11;
+                var checksum = (value.charAt(17).toUpperCase() !== 'X') ? parseInt(value.charAt(17), 10) : 10;
+                return checksum === sum;
+            }
+            
+            return true;
+        },
+        
+        /**
          * Validate Czech national identification number (RC)
          * Validate Czech national identification number (RC)
          * Examples:
          * Examples:
          * - Valid: 7103192745, 991231123
          * - Valid: 7103192745, 991231123

File diff suppressed because it is too large
+ 4 - 3
dist/js/bootstrapValidator.min.js


+ 1 - 0
dist/js/language/ar_MA.js

@@ -156,6 +156,7 @@
                 BR: 'البرازيل',
                 BR: 'البرازيل',
                 CH: 'سويسرا',
                 CH: 'سويسرا',
                 CL: 'تشيلي',
                 CL: 'تشيلي',
+                CN: 'الصين',
                 CZ: 'التشيك',
                 CZ: 'التشيك',
                 DK: 'الدنمارك',
                 DK: 'الدنمارك',
                 EE: 'إستونيا',
                 EE: 'إستونيا',

+ 1 - 0
dist/js/language/be_FR.js

@@ -156,6 +156,7 @@
                 BR: 'Brésil',
                 BR: 'Brésil',
                 CH: 'Suisse',
                 CH: 'Suisse',
                 CL: 'Chili',
                 CL: 'Chili',
+                CN: 'Chine',
                 CZ: 'tchèque',
                 CZ: 'tchèque',
                 DK: 'Danemark',
                 DK: 'Danemark',
                 EE: 'Estonie',
                 EE: 'Estonie',

+ 1 - 0
dist/js/language/be_NL.js

@@ -156,6 +156,7 @@
                 BR: 'Brazilië',
                 BR: 'Brazilië',
                 CH: 'Zwitserland',
                 CH: 'Zwitserland',
                 CL: 'Chili',
                 CL: 'Chili',
+                CN: 'China',
                 CZ: 'Tsjechische',
                 CZ: 'Tsjechische',
                 DK: 'Denemarken',
                 DK: 'Denemarken',
                 EE: 'Estland',
                 EE: 'Estland',

+ 1 - 0
dist/js/language/bg_BG.js

@@ -156,6 +156,7 @@
                 BR: 'Бразилия',
                 BR: 'Бразилия',
                 СН: 'Швейцария',
                 СН: 'Швейцария',
                 CL: 'Чили',
                 CL: 'Чили',
+                CN: 'Китай',
                 CZ: 'чех',
                 CZ: 'чех',
                 DK: 'Дания',
                 DK: 'Дания',
                 EE: 'Естония',
                 EE: 'Естония',

+ 1 - 0
dist/js/language/cs_CZ.js

@@ -156,6 +156,7 @@
                 BR: 'Brazílii',
                 BR: 'Brazílii',
                 CH: 'Švýcarsko',
                 CH: 'Švýcarsko',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'Čína',
                 CZ: 'Čechy',
                 CZ: 'Čechy',
                 DK: 'Dánsko',
                 DK: 'Dánsko',
                 EE: 'Estonsko',
                 EE: 'Estonsko',

+ 1 - 0
dist/js/language/da_DK.js

@@ -156,6 +156,7 @@
                 BR: 'Brasilien',
                 BR: 'Brasilien',
                 CH: 'Schweiz',
                 CH: 'Schweiz',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'Kina',
                 CZ: 'Tjekkisk',
                 CZ: 'Tjekkisk',
                 DK: 'Danmark',
                 DK: 'Danmark',
                 EE: 'Estland',
                 EE: 'Estland',

+ 1 - 0
dist/js/language/de_DE.js

@@ -156,6 +156,7 @@
                 BR: 'Brasilien',
                 BR: 'Brasilien',
                 CH: 'Schweiz',
                 CH: 'Schweiz',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'China',
                 CZ: 'Tschechisch',
                 CZ: 'Tschechisch',
                 DK: 'Dänemark',
                 DK: 'Dänemark',
                 EE: 'Estland',
                 EE: 'Estland',

+ 1 - 0
dist/js/language/en_US.js

@@ -156,6 +156,7 @@
                 BR: 'Brazil',
                 BR: 'Brazil',
                 CH: 'Switzerland',
                 CH: 'Switzerland',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'China',
                 CZ: 'Czech',
                 CZ: 'Czech',
                 DK: 'Denmark',
                 DK: 'Denmark',
                 EE: 'Estonia',
                 EE: 'Estonia',

+ 1 - 0
dist/js/language/es_CL.js

@@ -156,6 +156,7 @@
                 BR: 'Brasil',
                 BR: 'Brasil',
                 CH: 'Suiza',
                 CH: 'Suiza',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'China',
                 CZ: 'Checa',
                 CZ: 'Checa',
                 DK: 'Dinamarca',
                 DK: 'Dinamarca',
                 EE: 'Estonia',
                 EE: 'Estonia',

+ 1 - 0
dist/js/language/es_ES.js

@@ -156,6 +156,7 @@
                 BR: 'Brasil',
                 BR: 'Brasil',
                 CH: 'Suiza',
                 CH: 'Suiza',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'China',
                 CZ: 'Checa',
                 CZ: 'Checa',
                 DK: 'Dinamarca',
                 DK: 'Dinamarca',
                 EE: 'Estonia',
                 EE: 'Estonia',

+ 1 - 0
dist/js/language/fa_IR.js

@@ -156,6 +156,7 @@
                 BR: 'برزیل',
                 BR: 'برزیل',
                 CH: 'سوئیس',
                 CH: 'سوئیس',
                 CL: 'شیلی',
                 CL: 'شیلی',
+                CN: 'چین',
                 CZ: 'چک',
                 CZ: 'چک',
                 DK: 'دانمارک',
                 DK: 'دانمارک',
                 EE: 'استونی',
                 EE: 'استونی',

+ 1 - 0
dist/js/language/fr_FR.js

@@ -156,6 +156,7 @@
                 BR: 'Brésil',
                 BR: 'Brésil',
                 CH: 'Suisse',
                 CH: 'Suisse',
                 CL: 'Chili',
                 CL: 'Chili',
+                CN: 'Chine',
                 CZ: 'tchèque',
                 CZ: 'tchèque',
                 DK: 'Danemark',
                 DK: 'Danemark',
                 EE: 'Estonie',
                 EE: 'Estonie',

+ 1 - 0
dist/js/language/gr_EL.js

@@ -156,6 +156,7 @@
                 BR: 'Βραζιλία',
                 BR: 'Βραζιλία',
                 CH: 'Ελβετία',
                 CH: 'Ελβετία',
                 CL: 'Χιλή',
                 CL: 'Χιλή',
+                CN: 'Κίνα',
                 CZ: 'Τσεχία',
                 CZ: 'Τσεχία',
                 DK: 'Δανία',
                 DK: 'Δανία',
                 EE: 'Εσθονία',
                 EE: 'Εσθονία',

+ 1 - 0
dist/js/language/hu_HU.js

@@ -156,6 +156,7 @@
                 BR: 'brazil',
                 BR: 'brazil',
                 CH: 'svájci',
                 CH: 'svájci',
                 CL: 'chilei',
                 CL: 'chilei',
+                CN: 'Kína',
                 CZ: 'cseh',
                 CZ: 'cseh',
                 DK: 'dán',
                 DK: 'dán',
                 EE: 'észt',
                 EE: 'észt',

+ 2 - 1
dist/js/language/it_IT.js

@@ -156,6 +156,7 @@
                 BR: 'Brasile',
                 BR: 'Brasile',
                 CH: 'Svizzera',
                 CH: 'Svizzera',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'Cina',
                 CZ: 'Ceco',
                 CZ: 'Ceco',
                 DK: 'Danimarca',
                 DK: 'Danimarca',
                 EE: 'Estonia',
                 EE: 'Estonia',
@@ -230,7 +231,7 @@
             country: 'Si prega di inserire un numero di telefono valido per %s',
             country: 'Si prega di inserire un numero di telefono valido per %s',
             countries: {
             countries: {
                 BR: 'Brasile',
                 BR: 'Brasile',
-                CN: 'Porcellana',
+                CN: 'Cina',
                 DK: 'Danimarca',
                 DK: 'Danimarca',
                 ES: 'Spagna',
                 ES: 'Spagna',
                 FR: 'Francia',
                 FR: 'Francia',

+ 1 - 0
dist/js/language/ja_JP.js

@@ -156,6 +156,7 @@
                 BR: 'ブラジル',
                 BR: 'ブラジル',
                 CH: 'スイス',
                 CH: 'スイス',
                 CL: 'チリ',
                 CL: 'チリ',
+                CN: 'チャイナ',
                 CZ: 'チェコ',
                 CZ: 'チェコ',
                 DK: 'デンマーク',
                 DK: 'デンマーク',
                 EE: 'エストニア',
                 EE: 'エストニア',

+ 1 - 0
dist/js/language/nl_NL.js

@@ -156,6 +156,7 @@
                 BR: 'Brazilië',
                 BR: 'Brazilië',
                 CH: 'Zwitserland',
                 CH: 'Zwitserland',
                 CL: 'Chili',
                 CL: 'Chili',
+                CN: 'China',
                 CZ: 'Tsjechische',
                 CZ: 'Tsjechische',
                 DK: 'Denemarken',
                 DK: 'Denemarken',
                 EE: 'Estland',
                 EE: 'Estland',

+ 1 - 0
dist/js/language/pl_PL.js

@@ -156,6 +156,7 @@
                 BR: 'Brazylia',
                 BR: 'Brazylia',
                 CH: 'Szwajcaria',
                 CH: 'Szwajcaria',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'Chiny',
                 CZ: 'Czeska',
                 CZ: 'Czeska',
                 DK: 'Dania',
                 DK: 'Dania',
                 EE: 'Estonia',
                 EE: 'Estonia',

+ 1 - 0
dist/js/language/pt_BR.js

@@ -156,6 +156,7 @@
                 BR: 'Brasil',
                 BR: 'Brasil',
                 CH: 'Suíça',
                 CH: 'Suíça',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'China',
                 CZ: 'Checa',
                 CZ: 'Checa',
                 DK: 'Dinamarca',
                 DK: 'Dinamarca',
                 EE: 'Estônia',
                 EE: 'Estônia',

+ 1 - 0
dist/js/language/ro_RO.js

@@ -156,6 +156,7 @@
                 BR: 'Brazilia',
                 BR: 'Brazilia',
                 CH: 'Elvetia',
                 CH: 'Elvetia',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'China',
                 CZ: 'Cehia',
                 CZ: 'Cehia',
                 DK: 'Danemarca',
                 DK: 'Danemarca',
                 EE: 'Estonia',
                 EE: 'Estonia',

+ 1 - 0
dist/js/language/sv_SE.js

@@ -156,6 +156,7 @@
                 BR: 'Brasilien',
                 BR: 'Brasilien',
                 CH: 'Schweiz',
                 CH: 'Schweiz',
                 CL: 'Chile',
                 CL: 'Chile',
+                CN: 'Kina',
                 CZ: 'Tjeck',
                 CZ: 'Tjeck',
                 DK: 'Danmark',
                 DK: 'Danmark',
                 EE: 'Estland',
                 EE: 'Estland',

+ 1 - 0
dist/js/language/th_TH.js

@@ -156,6 +156,7 @@
                 BR: 'บราซิล',
                 BR: 'บราซิล',
                 CH: 'วิตเซอร์แลนด์',
                 CH: 'วิตเซอร์แลนด์',
                 CL: 'ชิลี',
                 CL: 'ชิลี',
+                CN: 'จีน',
                 CZ: 'เช็ก',
                 CZ: 'เช็ก',
                 DK: 'เดนมาร์ก',
                 DK: 'เดนมาร์ก',
                 EE: 'เอสโตเนีย',
                 EE: 'เอสโตเนีย',

+ 1 - 0
dist/js/language/tr_TR.js

@@ -156,6 +156,7 @@
                 BR: 'Brezilya',
                 BR: 'Brezilya',
                 CH: 'İsviçre',
                 CH: 'İsviçre',
                 CL: 'Şili',
                 CL: 'Şili',
+                CN: 'Çin',
                 CZ: 'Çek',
                 CZ: 'Çek',
                 DK: 'Danimarka',
                 DK: 'Danimarka',
                 EE: 'Estonya',
                 EE: 'Estonya',

+ 1 - 0
dist/js/language/vi_VN.js

@@ -156,6 +156,7 @@
                 BR: 'Brazil',
                 BR: 'Brazil',
                 CH: 'Thuỵ Sĩ',
                 CH: 'Thuỵ Sĩ',
                 CL: 'Chi Lê',
                 CL: 'Chi Lê',
+                CN: 'Trung Quốc',
                 CZ: 'Séc',
                 CZ: 'Séc',
                 DK: 'Đan Mạch',
                 DK: 'Đan Mạch',
                 EE: 'Estonia',
                 EE: 'Estonia',

+ 1 - 0
dist/js/language/zh_CN.js

@@ -156,6 +156,7 @@
                 BR: '巴西',
                 BR: '巴西',
                 CH: '瑞士',
                 CH: '瑞士',
                 CL: '智利',
                 CL: '智利',
+                CN: '中国',
                 CZ: '捷克',
                 CZ: '捷克',
                 DK: '丹麦',
                 DK: '丹麦',
                 EE: '爱沙尼亚',
                 EE: '爱沙尼亚',

+ 1 - 0
dist/js/language/zh_TW.js

@@ -156,6 +156,7 @@
                 BR: '巴西',
                 BR: '巴西',
                 CH: '瑞士',
                 CH: '瑞士',
                 CL: '智利',
                 CL: '智利',
+                CN: '中國',
                 CZ: '捷克',
                 CZ: '捷克',
                 DK: '丹麥',
                 DK: '丹麥',
                 EE: '愛沙尼亞',
                 EE: '愛沙尼亞',

+ 1 - 1
src/js/language/ar_MA.js

@@ -155,8 +155,8 @@
                 BG: 'بلغاريا',
                 BG: 'بلغاريا',
                 BR: 'البرازيل',
                 BR: 'البرازيل',
                 CH: 'سويسرا',
                 CH: 'سويسرا',
-                CN: 'الصين',
                 CL: 'تشيلي',
                 CL: 'تشيلي',
+                CN: 'الصين',
                 CZ: 'التشيك',
                 CZ: 'التشيك',
                 DK: 'الدنمارك',
                 DK: 'الدنمارك',
                 EE: 'إستونيا',
                 EE: 'إستونيا',

+ 1 - 1
src/js/language/en_US.js

@@ -156,7 +156,7 @@
                 BR: 'Brazil',
                 BR: 'Brazil',
                 CH: 'Switzerland',
                 CH: 'Switzerland',
                 CL: 'Chile',
                 CL: 'Chile',
-                CL: 'China',
+                CN: 'China',
                 CZ: 'Czech',
                 CZ: 'Czech',
                 DK: 'Denmark',
                 DK: 'Denmark',
                 EE: 'Estonia',
                 EE: 'Estonia',

+ 1 - 1
src/js/language/it_IT.js

@@ -231,7 +231,7 @@
             country: 'Si prega di inserire un numero di telefono valido per %s',
             country: 'Si prega di inserire un numero di telefono valido per %s',
             countries: {
             countries: {
                 BR: 'Brasile',
                 BR: 'Brasile',
-                CN: 'Porcellana',
+                CN: 'Cina',
                 DK: 'Danimarca',
                 DK: 'Danimarca',
                 ES: 'Spagna',
                 ES: 'Spagna',
                 FR: 'Francia',
                 FR: 'Francia',

+ 1 - 1
src/js/language/ja_JP.js

@@ -156,7 +156,7 @@
                 BR: 'ブラジル',
                 BR: 'ブラジル',
                 CH: 'スイス',
                 CH: 'スイス',
                 CL: 'チリ',
                 CL: 'チリ',
-                CN: '中国',
+                CN: 'チャイナ',
                 CZ: 'チェコ',
                 CZ: 'チェコ',
                 DK: 'デンマーク',
                 DK: 'デンマーク',
                 EE: 'エストニア',
                 EE: 'エストニア',

+ 1 - 0
src/js/language/th_TH.js

@@ -156,6 +156,7 @@
                 BR: 'บราซิล',
                 BR: 'บราซิล',
                 CH: 'วิตเซอร์แลนด์',
                 CH: 'วิตเซอร์แลนด์',
                 CL: 'ชิลี',
                 CL: 'ชิลี',
+                CN: 'จีน',
                 CZ: 'เช็ก',
                 CZ: 'เช็ก',
                 DK: 'เดนมาร์ก',
                 DK: 'เดนมาร์ก',
                 EE: 'เอสโตเนีย',
                 EE: 'เอสโตเนีย',

+ 503 - 159
src/js/validator/id.js

@@ -319,193 +319,537 @@
         /**
         /**
          * Validate Chinese citizen identification number
          * Validate Chinese citizen identification number
          *
          *
+         * Rules:
+         * - For current 18-digit system (since 1st Oct 1999, defined by GB11643—1999 national standard):
+         *     - Digit 0-5: Must be a valid administrative division code of China PR.
+         *     - Digit 6-13: Must be a valid YYYYMMDD date of birth. A future date is tolerated.
+         *     - Digit 14-16: Order code, any integer.
+         *     - Digit 17: An ISO 7064:1983, MOD 11-2 checksum.
+         *       Both upper/lower case of X are tolerated.
+         * - For deprecated 15-digit system:
+         *     - Digit 0-5: Must be a valid administrative division code of China PR.
+         *     - Digit 6-11: Must be a valid YYMMDD date of birth, indicating the year of 19XX.
+         *     - Digit 12-14: Order code, any integer.
+         * Lists of valid administrative division codes of China PR can be seen here:
+         * <http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/>
+         * Published and maintained by National Bureau of Statistics of China PR.
+         * NOTE: Current and deprecated codes MUST BOTH be considered valid.
+         * Many Chinese citizens born in once existed administrative divisions!
+         *
          * @see http://en.wikipedia.org/wiki/Resident_Identity_Card#Identity_card_number
          * @see http://en.wikipedia.org/wiki/Resident_Identity_Card#Identity_card_number
          * @param {String} value The ID
          * @param {String} value The ID
          * @returns {Boolean}
          * @returns {Boolean}
          */
          */
         _cn: function(value) {
         _cn: function(value) {
-            /**
-             * Rules:
-             * - For current 18-digit system (since 1st Oct 1999, defined by GB11643—1999 national 
-             *   standard): 
-             *     - Digit 0-5: Must be a valid administrative division code of China PR.
-             *     - Digit 6-13: Must be a valid YYYYMMDD date of birth. A future date is tolerated.
-             *     - Digit 14-16: Order code, any integer. 
-             *     - Digit 17: An ISO 7064:1983, MOD 11-2 checksum. 
-             *       Both upper/lower case of X are tolerated. 
-             * - For deprecated 15-digit system: 
-             *     - Digit 0-5: Must be a valid administrative division code of China PR. 
-             *     - Digit 6-11: Must be a valid YYMMDD date of birth, indicating the year of 19XX. 
-             *     - Digit 12-14: Order code, any integer. 
-             * Lists of valid administrative division codes of China PR can be seen here: 
-             * <http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/>
-             * Published and maintanced by National Bureau of Statistics of China PR. 
-             * NOTE: Current and deprecated codes MUST BOTH be considered valid - many Chinese 
-             * citizens born in once existed admistrative divisions! 
-             */
-            
             // Basic format check (18 or 15 digits, considering X in checksum)
             // Basic format check (18 or 15 digits, considering X in checksum)
             value = value.trim();
             value = value.trim();
-            if (!/^\d{15}$/.test(value) && !/^\d{17}[\dXx]{1}$/.test(value)) { return false; }
+            if (!/^\d{15}$/.test(value) && !/^\d{17}[\dXx]{1}$/.test(value)) {
+                return false;
+            }
             
             
             // Check China PR Administrative division code
             // Check China PR Administrative division code
-            var china_admin_div_codes = {11:{0:[0],1:[[0,9],[11,17]],2:[0,[28,29]]},12:{0:[0
-            ],1:[[0,16]],2:[0,21,23,25]},13:{0:[0],1:[[0,5],[7,8],21,[23,33],[81,85]],2:
-            [[0,5],[7,9],[23,25],27,[29,30],81,83],3:[[0,4],[21,24]],4:[[0,4],6,21,[23,35],81],
-            5:[[0,3],[21,35],[81,82]],6:[[0,4],[21,38],[81,84]],7:[[0,3],[5,6],[21,33]],8:[[
-            0,4],[21,28]],9:[[0,3],[21,30],[81,84]],10:[[0,3],[22,26],28,[81,82]],11:[[0,2],[
-            21,28],[81,82]]},14:{0:[0],1:[[0,1],[5,10],[21,23],81],2:[[0,3],[11,12],[21,27]]
-            ,3:[[0,3],11,[21,22]],4:[[0,2],11,21,[23,31],81],5:[[0,2],[21,22],[24,25],81],6:
-            [[0,3],[21,24]],7:[[0,2],[21,29],81],8:[[0,2],[21,30],[81,82]],9:[[0,2],[21,32],81
-            ],10:[[0,2],[21,34],[81,82]],11:[[0,2],[21,30],[81,82]],23:[[0,3],[22,23],[25,30],
-            [32,33]]},15:{0:[0],1:[[0,5],[21,25]],2:[[0,7],[21,23]],3:[[0,4]],4:[[0,4],[
-            21,26],[28,30]],5:[[0,2],[21,26],81],6:[[0,2],[21,27]],7:[[0,3],[21,27],[81,85]],
-            8:[[0,2],[21,26]],9:[[0,2],[21,29],81],22:[[0,2],[21,24]],25:[[0,2],[22,31]],
-            26:[[0,2],[24,27],[29,32],34],28:[[0,1],[22,27]],29:[0,[21,23]]},21:{0:[0],1
-            :[[0,6],[11,14],[22,24],81],2:[[0,4],[11,13],24,[81,83]],3:[[0,4],11,21,23,81],4:[
-            [0,4],11,[21,23]],5:[[0,5],[21,22]],6:[[0,4],24,[81,82]],7:[[0,3],11,[26,27],[81,
-            82]],8:[[0,4],11,[81,82]],9:[[0,5],11,[21,22]],10:[[0,5],11,21,81],11:[[0,3],[21
-            ,22]],12:[[0,2],4,21,[23,24],[81,82]],13:[[0,3],[21,22],24,[81,82]],14:[[0,4],[21,
-            22],81]},22:{0:[0],1:[[0,6],12,22,[81,83]],2:[[0,4],11,21,[81,84]],3:[[0,3],[
-            22,23],[81,82]],4:[[0,3],[21,22]],5:[[0,3],21,[23,24],[81,82]],6:[[0,2],[4,5],[21,
-            23],25,81],7:[[0,2],[21,24],81],8:[[0,2],[21,22],[81,82]],24:[[0,6],24,26]},23:{
-            0:[0],1:[[0,12],21,[23,29],[81,84]],2:[[0,8],21,[23,25],27,[29,31],81],3:[[0,7],
-            21,[81,82]],4:[[0,7],[21,22]],5:[[0,3],[5,6],[21,24]],6:[[0,6],[21,24]],7:[[0,16
-            ],22,81],8:[[0,5],11,22,26,28,33,[81,82]],9:[[0,4],21],10:[[0,5],[24,25],81,[83,85
-            ]],11:[[0,2],21,[23,24],[81,82]],12:[[0,2],[21,26],[81,83]],27:[[0,4],[21,23]]},
-            31:{0:[0],1:[[0,1],[3,10],[12,20]],2:[0,30]},32:{0:[0],1:[[0,7],11,[13,18]
-            ,[24,25]],2:[[0,6],11,[81,82]],3:[[0,5],[11,12],[21,24],[81,82]],4:[[0,2],[4,5],[
-            11,12],[81,82]],5:[[0,9],[81,85]],6:[[0,2],[11,12],21,23,[81,84]],7:[[0,1],3,[5,6]
-            ,[21,24]],8:[[0,4],11,26,[29,31]],9:[[0,3],[21,25],28,[81,82]],10:[[0,3],[11,12],
-            23,81,84,88],11:[[0,2],[11,12],[81,83]],12:[[0,4],[81,84]],13:[[0,2],11,[21,24]]},
-            33:{0:[0],1:[[0,6],[8,10],22,27,[82,83],85],2:[[0,1],[3,6],[11,12],[25,26],[81,
-            83]],3:[[0,4],22,24,[26,29],[81,82]],4:[[0,2],11,21,24,[81,83]],5:[[0,3],[21,23]],
-            6:[[0,2],21,24,[81,83]],7:[[0,3],23,[26,27],[81,84]],8:[[0,3],22,[24,25],81],9:[
-            [0,3],[21,22]],10:[[0,4],[21,24],[81,82]],11:[[0,2],[21,27],81]},34:{0:[0],1:[
-            [0,4],11,[21,24],81],2:[[0,4],[7,8],[21,23],25],3:[[0,4],11,[21,23]],4:[[0,6],21],
-            5:[[0,4],6,[21,23]],6:[[0,4],21],7:[[0,3],11,21],8:[[0,3],11,[22,28],81],10:[[
-            0,4],[21,24]],11:[[0,3],22,[24,26],[81,82]],12:[[0,4],[21,22],[25,26],82],13:[[0,2
-            ],[21,24]],14:[[0,2],[21,24]],15:[[0,3],[21,25]],16:[[0,2],[21,23]],17:[[0,2],[
-            21,23]],18:[[0,2],[21,25],81]},35:{0:[0],1:[[0,5],11,[21,25],28,[81,82]],2:[[0
-            ,6],[11,13]],3:[[0,5],22],4:[[0,3],21,[23,30],81],5:[[0,5],21,[24,27],[81,83]],6
-            :[[0,3],[22,29],81],7:[[0,2],[21,25],[81,84]],8:[[0,2],[21,25],81],9:[[0,2],[21,26
-            ],[81,82]]},36:{0:[0],1:[[0,5],11,[21,24]],2:[[0,3],22,81],3:[[0,2],13,[21,23]
-            ],4:[[0,3],21,[23,30],[81,82]],5:[[0,2],21],6:[[0,2],22,81],7:[[0,2],[21,35],[81
-            ,82]],8:[[0,3],[21,30],81],9:[[0,2],[21,26],[81,83]],10:[[0,2],[21,30]],11:[[0,2
-            ],[21,30],81]},37:{0:[0],1:[[0,5],[12,13],[24,26],81],2:[[0,3],5,[11,14],[81,85]
-            ],3:[[0,6],[21,23]],4:[[0,6],81],5:[[0,3],[21,23]],6:[[0,2],[11,13],34,[81,87]],
-            7:[[0,5],[24,25],[81,86]],8:[[0,2],11,[26,32],[81,83]],9:[[0,3],11,21,23,[82,83]],
-            10:[[0,2],[81,83]],11:[[0,3],[21,22]],12:[[0,3]],13:[[0,2],[11,12],[21,29]],14
-            :[[0,2],[21,28],[81,82]],15:[[0,2],[21,26],81],16:[[0,2],[21,26]],17:[[0,2],[21,28
-            ]]},41:{0:[0],1:[[0,6],8,22,[81,85]],2:[[0,5],11,[21,25]],3:[[0,7],11,[22,29],
-            81],4:[[0,4],11,[21,23],25,[81,82]],5:[[0,3],[5,6],[22,23],[26,27],81],6:[[0,3],11
-            ,[21,22]],7:[[0,4],11,21,[24,28],[81,82]],8:[[0,4],11,[21,23],25,[81,83]],9:[[0,2]
-            ,[22,23],[26,28]],10:[[0,2],[23,25],[81,82]],11:[[0,4],[21,23]],12:[[0,2],[21,22],
-            24,[81,82]],13:[[0,3],[21,30],81],14:[[0,3],[21,26],81],15:[[0,3],[21,28]],16:[[
-            0,2],[21,28],81],17:[[0,2],[21,29]],90:[[0,1]]},42:{0:[0],1:[[0,7],[11,17]],
-            2:[[0,5],22,81],3:[[0,3],[21,25],81],5:[[0,6],[25,29],[81,83]],6:[[0,2],[6,7],[
-            24,26],[82,84]],7:[[0,4]],8:[[0,2],4,[21,22],81],9:[[0,2],[21,23],[81,82],84],10
-            :[[0,3],[22,24],81,83,87],11:[[0,2],[21,27],[81,82]],12:[[0,2],[21,24],81],13:[[0,
-            3],21,81],90:[0,[4,6],21],28:[[0,2],[22,23],[25,28]]},43:{0:[0],1:[[0,5],[11,
-            12],[21,22],24,81],2:[[0,4],11,21,[23,25],81],3:[[0,2],4,21,[81,82]],4:[[0,1],[5,8
-            ],12,[21,24],26,[81,82]],5:[[0,3],11,[21,25],[27,29],81],6:[[0,3],11,21,[23,24],26,[
-            81,82]],7:[[0,3],[21,26],81],8:[[0,2],11,[21,22]],9:[[0,3],[21,23],81],10:[[0,3]
-            ,[21,28],81],11:[[0,3],[21,29]],12:[[0,2],[21,30],81],13:[[0,2],[21,22],[81,82]],
-            31:[[0,1],[22,27],30]},44:{0:[0],1:[[0,7],[11,16],[83,84]],2:[[0,5],[21,22],24
-            ,29,[32,33],[81,82]],3:[[0,1],[3,8]],4:[[0,4]],5:[[0,1],[6,15],23,[82,83]],6:[[0
-            ,1],[4,8]],7:[[0,1],[3,5],81,[83,85]],8:[[0,4],11,23,25,[81,83]],9:[[0,3],23,[81,
-            83]],12:[[0,3],[23,26],[83,84]],13:[[0,3],[22,24],81],14:[[0,2],[21,24],[26,27],81
-            ],15:[[0,2],21,23,81],16:[[0,2],[21,25]],17:[[0,2],21,23,81],18:[[0,3],21,23,[25
-            ,27],[81,82]],19:[0],20:[0],51:[[0,3],[21,22]],52:[[0,3],[21,22],24,81],53:[[0
-            ,2],[21,23],81]},45:{0:[0],1:[[0,9],[21,27]],2:[[0,5],[21,26]],3:[[0,5],[11,12
-            ],[21,32]],4:[[0,1],[3,6],11,[21,23],81],5:[[0,3],12,21],6:[[0,3],21,81],7:[[0,3
-            ],[21,22]],8:[[0,4],21,81],9:[[0,3],[21,24],81],10:[[0,2],[21,31]],11:[[0,2],[21
-            ,23]],12:[[0,2],[21,29],81],13:[[0,2],[21,24],81],14:[[0,2],[21,25],81]},46:{0
-            :[0],1:[[0,1],[5,8]],2:[[0,1]],3:[0,[21,23]],90:[[0,3],[5,7],[21,39]]},50:{0
-            :[0],1:[[0,19]],2:[0,[22,38],[40,43]],3:[0,[81,84]]},51:{0:[0],1:[[0,1],[4,8
-            ],[12,15],[21,24],29,[31,32],[81,84]],3:[[0,4],11,[21,22]],4:[[0,3],11,[21,22]],5:
-            [[0,4],[21,22],[24,25]],6:[[0,1],3,23,26,[81,83]],7:[[0,1],[3,4],[22,27],81],8:[[0
-            ,2],[11,12],[21,24]],9:[[0,4],[21,23]],10:[[0,2],11,[24,25],28],11:[[0,2],[11,13],
-            [23,24],26,29,[32,33],81],13:[[0,4],[21,25],81],14:[[0,2],[21,25]],15:[[0,3],[21,
-            29]],16:[[0,3],[21,23],81],17:[[0,3],[21,25],81],18:[[0,3],[21,27]],19:[[0,3],[
-            21,23]],20:[[0,2],[21,22],81],32:[0,[21,33]],33:[0,[21,38]],34:[[0,1],[22,37]]},
-            52:{0:[0],1:[[0,3],[11,15],[21,23],81],2:[[0,1],3,[21,22]],3:[[0,3],[21,30],[
-            81,82]],4:[[0,2],[21,25]],5:[[0,2],[21,27]],6:[[0,3],[21,28]],22:[[0,1],[22,30]]
-            ,23:[[0,1],[22,28]],24:[[0,1],[22,28]],26:[[0,1],[22,36]],27:[[0,2],[22,23],[25,
-            32]]},53:{0:[0],1:[[0,3],[11,14],[21,22],[24,29],81],34:[0,[21,23]],3:[[0,2],[
-            21,26],28,81],4:[[0,2],[21,28]],5:[[0,2],[21,24]],6:[[0,2],[21,30]],7:[[0,2],[21
-            ,24]],8:[[0,2],[21,29]],9:[[0,2],[21,27]],33:[0,21,[23,25]],35:[0,[21,28]],23:
-            [[0,1],[22,29],31],25:[[0,4],[22,32]],26:[[0,1],[21,28]],27:[[0,1],[22,30]],28:[
-            [0,1],[22,23]],29:[[0,1],[22,32]],31:[0,[2,3],[22,24]]},54:{0:[0],1:[[0,2],[21
-            ,27]],21:[0,[21,29],[32,33]],22:[0,[21,29],[31,33]],23:[[0,1],[22,38]],24:[0,[21
-            ,31]],25:[0,[21,27]],26:[0,[21,27]]},61:{0:[0],1:[[0,4],[11,16],22,[24,26]],
-            2:[[0,4],22],3:[[0,4],[21,24],[26,31]],4:[[0,4],[22,31],81],5:[[0,2],[21,28],[81
-            ,82]],6:[[0,2],[21,32]],7:[[0,2],[21,30]],8:[[0,2],[21,31]],9:[[0,2],[21,29]],
-            10:[[0,2],[21,26]]},62:{0:[0],1:[[0,5],11,[21,23]],2:[[0,1]],3:[[0,2],21],
-            4:[[0,3],[21,23]],5:[[0,3],[21,25]],6:[[0,2],[21,23]],7:[[0,2],[21,25]],8:[[0,
-            2],[21,26]],9:[[0,2],[21,24],[81,82]],10:[[0,2],[21,27]],11:[[0,2],[21,26]],12:[
-            [0,2],[21,28]],24:[0,21,[24,29]],26:[0,21,[23,30]],29:[[0,1],[21,27]],30:[[0,1],
-            [21,27]]},63:{0:[0],1:[[0,5],[21,23]],2:[0,2,[21,25]],21:[0,[21,23],[26,28]],
-            22:[0,[21,24]],23:[0,[21,24]],25:[0,[21,25]],26:[0,[21,26]],27:[[0,1],[21,26]]
-            ,28:[[0,2],[21,23]]},64:{0:[0],1:[[0,1],[4,6],[21,22],81],2:[[0,3],5,[21,23]],
-            3:[[0,3],[21,24],81],4:[[0,2],[21,25]],5:[[0,2],[21,22]]},65:{0:[0],1:[[0,9]
-            ,21],2:[[0,5]],32:[[0,1],[21,27]],40:[0,[2,3],[21,28]],42:[[0,2],21,[23,26]],
-            43:[[0,1],[21,26]],21:[[0,1],[22,23]],22:[[0,1],[22,23]],23:[[0,3],[23,25],[27,
-            28]],90:[[0,4]],27:[[0,2],[22,23]],28:[[0,1],[22,29]],29:[[0,1],[22,29]],30:[[
-            0,1],[22,24]],31:[[0,1],[21,31]]},71:{0:[0]},81:{0:[0]},82:{0:[0]}};
+            var adminDivisionCodes = {
+                11: {
+                    0: [0],
+                    1: [[0, 9], [11, 17]],
+                    2: [0, [28, 29]]
+                },
+                12: {
+                    0: [0],
+                    1: [[0, 16]],
+                    2: [0, 21, 23, 25]
+                },
+                13: {
+                    0: [0],
+                    1: [[0, 5], [7, 8], 21, [23, 33], [81, 85]],
+                    2: [[0, 5], [7, 9], [23, 25], 27, [29, 30], 81, 83],
+                    3: [[0, 4], [21, 24]],
+                    4: [[0, 4], 6, 21, [23, 35], 81],
+                    5: [[0, 3], [21, 35], [81, 82]],
+                    6: [[0, 4], [21, 38], [81, 84]],
+                    7: [[0, 3], [5, 6], [21, 33]],
+                    8: [[0, 4], [21, 28]],
+                    9: [[0, 3], [21, 30], [81, 84]],
+                    10: [[0, 3], [22, 26], 28, [81, 82]],
+                    11: [[0, 2], [21, 28], [81, 82]]
+                },
+                14: {
+                    0: [0],
+                    1: [[0, 1], [5, 10], [21, 23], 81],
+                    2: [[0, 3], [11, 12], [21, 27]],
+                    3: [[0, 3], 11, [21, 22]],
+                    4: [[0, 2], 11, 21, [23, 31], 81],
+                    5: [[0, 2], [21, 22], [24, 25], 81],
+                    6: [[0, 3], [21, 24]],
+                    7: [[0, 2], [21, 29], 81],
+                    8: [[0, 2], [21, 30], [81, 82]],
+                    9: [[0, 2], [21, 32], 81],
+                    10: [[0, 2], [21, 34], [81, 82]],
+                    11: [[0, 2], [21, 30], [81, 82]],
+                    23: [[0, 3], [22, 23], [25, 30], [32, 33]]
+                },
+                15: {
+                    0: [0],
+                    1: [[0, 5], [21, 25]],
+                    2: [[0, 7], [21, 23]],
+                    3: [[0, 4]],
+                    4: [[0, 4], [21, 26], [28, 30]],
+                    5: [[0, 2], [21, 26], 81],
+                    6: [[0, 2], [21, 27]],
+                    7: [[0, 3], [21, 27], [81, 85]],
+                    8: [[0, 2], [21, 26]],
+                    9: [[0, 2], [21, 29], 81],
+                    22: [[0, 2], [21, 24]],
+                    25: [[0, 2], [22, 31]],
+                    26: [[0, 2], [24, 27], [29, 32], 34],
+                    28: [[0, 1], [22, 27]],
+                    29: [0, [21, 23]]
+                },
+                21: {
+                    0: [0],
+                    1: [[0, 6], [11, 14], [22, 24], 81],
+                    2: [[0, 4], [11, 13], 24, [81, 83]],
+                    3: [[0, 4], 11, 21, 23, 81],
+                    4: [[0, 4], 11, [21, 23]],
+                    5: [[0, 5], [21, 22]],
+                    6: [[0, 4], 24, [81, 82]],
+                    7: [[0, 3], 11, [26, 27], [81, 82]],
+                    8: [[0, 4], 11, [81, 82]],
+                    9: [[0, 5], 11, [21, 22]],
+                    10: [[0, 5], 11, 21, 81],
+                    11: [[0, 3], [21, 22]],
+                    12: [[0, 2], 4, 21, [23, 24], [81, 82]],
+                    13: [[0, 3], [21, 22], 24, [81, 82]],
+                    14: [[0, 4], [21, 22], 81]
+                },
+                22: {
+                    0: [0],
+                    1: [[0, 6], 12, 22, [81, 83]],
+                    2: [[0, 4], 11, 21, [81, 84]],
+                    3: [[0, 3], [22, 23], [81, 82]],
+                    4: [[0, 3], [21, 22]],
+                    5: [[0, 3], 21, [23, 24], [81, 82]],
+                    6: [[0, 2], [4, 5], [21, 23], 25, 81],
+                    7: [[0, 2], [21, 24], 81],
+                    8: [[0, 2], [21, 22], [81, 82]],
+                    24: [[0, 6], 24, 26]
+                },
+                23: {
+                    0: [0],
+                    1: [[0, 12], 21, [23, 29], [81, 84]],
+                    2: [[0, 8], 21, [23, 25], 27, [29, 31], 81],
+                    3: [[0, 7], 21, [81, 82]],
+                    4: [[0, 7], [21, 22]],
+                    5: [[0, 3], [5, 6], [21, 24]],
+                    6: [[0, 6], [21, 24]],
+                    7: [[0, 16], 22, 81],
+                    8: [[0, 5], 11, 22, 26, 28, 33, [81, 82]],
+                    9: [[0, 4], 21],
+                    10: [[0, 5], [24, 25], 81, [83, 85]],
+                    11: [[0, 2], 21, [23, 24], [81, 82]],
+                    12: [[0, 2], [21, 26], [81, 83]],
+                    27: [[0, 4], [21, 23]]
+                },
+                31: {
+                    0: [0],
+                    1: [[0, 1], [3, 10], [12, 20]],
+                    2: [0, 30]
+                },
+                32: {
+                    0: [0],
+                    1: [[0, 7], 11, [13, 18], [24, 25]],
+                    2: [[0, 6], 11, [81, 82]],
+                    3: [[0, 5], [11, 12], [21, 24], [81, 82]],
+                    4: [[0, 2], [4, 5], [11, 12], [81, 82]],
+                    5: [[0, 9], [81, 85]],
+                    6: [[0, 2], [11, 12], 21, 23, [81, 84]],
+                    7: [[0, 1], 3, [5, 6], [21, 24]],
+                    8: [[0, 4], 11, 26, [29, 31]],
+                    9: [[0, 3], [21, 25], 28, [81, 82]],
+                    10: [[0, 3], [11, 12], 23, 81, 84, 88],
+                    11: [[0, 2], [11, 12], [81, 83]],
+                    12: [[0, 4], [81, 84]],
+                    13: [[0, 2], 11, [21, 24]]
+                },
+                33: {
+                    0: [0],
+                    1: [[0, 6], [8, 10], 22, 27, [82, 83], 85],
+                    2: [[0, 1], [3, 6], [11, 12], [25, 26], [81, 83]],
+                    3: [[0, 4], 22, 24, [26, 29], [81, 82]],
+                    4: [[0, 2], 11, 21, 24, [81, 83]],
+                    5: [[0, 3], [21, 23]],
+                    6: [[0, 2], 21, 24, [81, 83]],
+                    7: [[0, 3], 23, [26, 27], [81, 84]],
+                    8: [[0, 3], 22, [24, 25], 81],
+                    9: [[0, 3], [21, 22]],
+                    10: [[0, 4], [21, 24], [81, 82]],
+                    11: [[0, 2], [21, 27], 81]
+                },
+                34: {
+                    0: [0],
+                    1: [[0, 4], 11, [21, 24], 81],
+                    2: [[0, 4], [7, 8], [21, 23], 25],
+                    3: [[0, 4], 11, [21, 23]],
+                    4: [[0, 6], 21],
+                    5: [[0, 4], 6, [21, 23]],
+                    6: [[0, 4], 21],
+                    7: [[0, 3], 11, 21],
+                    8: [[0, 3], 11, [22, 28], 81],
+                    10: [[0, 4], [21, 24]],
+                    11: [[0, 3], 22, [24, 26], [81, 82]],
+                    12: [[0, 4], [21, 22], [25, 26], 82],
+                    13: [[0, 2], [21, 24]],
+                    14: [[0, 2], [21, 24]],
+                    15: [[0, 3], [21, 25]],
+                    16: [[0, 2], [21, 23]],
+                    17: [[0, 2], [21, 23]],
+                    18: [[0, 2], [21, 25], 81]
+                },
+                35: {
+                    0: [0],
+                    1: [[0, 5], 11, [21, 25], 28, [81, 82]],
+                    2: [[0, 6], [11, 13]],
+                    3: [[0, 5], 22],
+                    4: [[0, 3], 21, [23, 30], 81],
+                    5: [[0, 5], 21, [24, 27], [81, 83]],
+                    6: [[0, 3], [22, 29], 81],
+                    7: [[0, 2], [21, 25], [81, 84]],
+                    8: [[0, 2], [21, 25], 81],
+                    9: [[0, 2], [21, 26], [81, 82]]
+                },
+                36: {
+                    0: [0],
+                    1: [[0, 5], 11, [21, 24]],
+                    2: [[0, 3], 22, 81],
+                    3: [[0, 2], 13, [21, 23]],
+                    4: [[0, 3], 21, [23, 30], [81, 82]],
+                    5: [[0, 2], 21],
+                    6: [[0, 2], 22, 81],
+                    7: [[0, 2], [21, 35], [81, 82]],
+                    8: [[0, 3], [21, 30], 81],
+                    9: [[0, 2], [21, 26], [81, 83]],
+                    10: [[0, 2], [21, 30]],
+                    11: [[0, 2], [21, 30], 81]
+                },
+                37: {
+                    0: [0],
+                    1: [[0, 5], [12, 13], [24, 26], 81],
+                    2: [[0, 3], 5, [11, 14], [81, 85]],
+                    3: [[0, 6], [21, 23]],
+                    4: [[0, 6], 81],
+                    5: [[0, 3], [21, 23]],
+                    6: [[0, 2], [11, 13], 34, [81, 87]],
+                    7: [[0, 5], [24, 25], [81, 86]],
+                    8: [[0, 2], 11, [26, 32], [81, 83]],
+                    9: [[0, 3], 11, 21, 23, [82, 83]],
+                    10: [[0, 2], [81, 83]],
+                    11: [[0, 3], [21, 22]],
+                    12: [[0, 3]],
+                    13: [[0, 2], [11, 12], [21, 29]],
+                    14: [[0, 2], [21, 28], [81, 82]],
+                    15: [[0, 2], [21, 26], 81],
+                    16: [[0, 2], [21, 26]],
+                    17: [[0, 2], [21, 28]]
+                },
+                41: {
+                    0: [0],
+                    1: [[0, 6], 8, 22, [81, 85]],
+                    2: [[0, 5], 11, [21, 25]],
+                    3: [[0, 7], 11, [22, 29], 81],
+                    4: [[0, 4], 11, [21, 23], 25, [81, 82]],
+                    5: [[0, 3], [5, 6], [22, 23], [26, 27], 81],
+                    6: [[0, 3], 11, [21, 22]],
+                    7: [[0, 4], 11, 21, [24, 28], [81, 82]],
+                    8: [[0, 4], 11, [21, 23], 25, [81, 83]],
+                    9: [[0, 2], [22, 23], [26, 28]],
+                    10: [[0, 2], [23, 25], [81, 82]],
+                    11: [[0, 4], [21, 23]],
+                    12: [[0, 2], [21, 22], 24, [81, 82]],
+                    13: [[0, 3], [21, 30], 81],
+                    14: [[0, 3], [21, 26], 81],
+                    15: [[0, 3], [21, 28]],
+                    16: [[0, 2], [21, 28], 81],
+                    17: [[0, 2], [21, 29]],
+                    90: [[0, 1]]
+                },
+                42: {
+                    0: [0],
+                    1: [[0, 7], [11, 17]],
+                    2: [[0, 5], 22, 81],
+                    3: [[0, 3], [21, 25], 81],
+                    5: [[0, 6], [25, 29], [81, 83]],
+                    6: [[0, 2], [6, 7], [24, 26], [82, 84]],
+                    7: [[0, 4]],
+                    8: [[0, 2], 4, [21, 22], 81],
+                    9: [[0, 2], [21, 23], [81, 82], 84],
+                    10: [[0, 3], [22, 24], 81, 83, 87],
+                    11: [[0, 2], [21, 27], [81, 82]],
+                    12: [[0, 2], [21, 24], 81],
+                    13: [[0, 3], 21, 81],
+                    28: [[0, 2], [22, 23], [25, 28]],
+                    90: [0, [4, 6], 21]
+                },
+                43: {
+                    0: [0],
+                    1: [[0, 5], [11, 12], [21, 22], 24, 81],
+                    2: [[0, 4], 11, 21, [23, 25], 81],
+                    3: [[0, 2], 4, 21, [81, 82]],
+                    4: [[0, 1], [5, 8], 12, [21, 24], 26, [81, 82]],
+                    5: [[0, 3], 11, [21, 25], [27, 29], 81],
+                    6: [[0, 3], 11, 21, [23, 24], 26, [81, 82]],
+                    7: [[0, 3], [21, 26], 81],
+                    8: [[0, 2], 11, [21, 22]],
+                    9: [[0, 3], [21, 23], 81],
+                    10: [[0, 3], [21, 28], 81],
+                    11: [[0, 3], [21, 29]],
+                    12: [[0, 2], [21, 30], 81],
+                    13: [[0, 2], [21, 22], [81, 82]],
+                    31: [[0, 1], [22, 27], 30]
+                },
+                44: {
+                    0: [0],
+                    1: [[0, 7], [11, 16], [83, 84]],
+                    2: [[0, 5], [21, 22], 24, 29, [32, 33], [81, 82]],
+                    3: [[0, 1], [3, 8]],
+                    4: [[0, 4]],
+                    5: [[0, 1], [6, 15], 23, [82, 83]],
+                    6: [[0, 1], [4, 8]],
+                    7: [[0, 1], [3, 5], 81, [83, 85]],
+                    8: [[0, 4], 11, 23, 25, [81, 83]],
+                    9: [[0, 3], 23, [81, 83]],
+                    12: [[0, 3], [23, 26], [83, 84]],
+                    13: [[0, 3], [22, 24], 81],
+                    14: [[0, 2], [21, 24], [26, 27], 81],
+                    15: [[0, 2], 21, 23, 81],
+                    16: [[0, 2], [21, 25]],
+                    17: [[0, 2], 21, 23, 81],
+                    18: [[0, 3], 21, 23, [25, 27], [81, 82]],
+                    19: [0],
+                    20: [0],
+                    51: [[0, 3], [21, 22]],
+                    52: [[0, 3], [21, 22], 24, 81],
+                    53: [[0, 2], [21, 23], 81]
+                },
+                45: {
+                    0: [0],
+                    1: [[0, 9], [21, 27]],
+                    2: [[0, 5], [21, 26]],
+                    3: [[0, 5], [11, 12], [21, 32]],
+                    4: [[0, 1], [3, 6], 11, [21, 23], 81],
+                    5: [[0, 3], 12, 21],
+                    6: [[0, 3], 21, 81],
+                    7: [[0, 3], [21, 22]],
+                    8: [[0, 4], 21, 81],
+                    9: [[0, 3], [21, 24], 81],
+                    10: [[0, 2], [21, 31]],
+                    11: [[0, 2], [21, 23]],
+                    12: [[0, 2], [21, 29], 81],
+                    13: [[0, 2], [21, 24], 81],
+                    14: [[0, 2], [21, 25], 81]
+                },
+                46: {
+                    0: [0],
+                    1: [[0, 1], [5, 8]],
+                    2: [[0, 1]],
+                    3: [0, [21, 23]],
+                    90: [[0, 3], [5, 7], [21, 39]]
+                },
+                50: {
+                    0: [0],
+                    1: [[0, 19]],
+                    2: [0, [22, 38], [40, 43]],
+                    3: [0, [81, 84]]
+                },
+                51: {
+                    0: [0],
+                    1: [[0, 1], [4, 8], [12, 15], [21, 24], 29, [31, 32], [81, 84]],
+                    3: [[0, 4], 11, [21, 22]],
+                    4: [[0, 3], 11, [21, 22]],
+                    5: [[0, 4], [21, 22], [24, 25]],
+                    6: [[0, 1], 3, 23, 26, [81, 83]],
+                    7: [[0, 1], [3, 4], [22, 27], 81],
+                    8: [[0, 2], [11, 12], [21, 24]],
+                    9: [[0, 4], [21, 23]],
+                    10: [[0, 2], 11, [24, 25], 28],
+                    11: [[0, 2], [11, 13], [23, 24], 26, 29, [32, 33], 81],
+                    13: [[0, 4], [21, 25], 81],
+                    14: [[0, 2], [21, 25]],
+                    15: [[0, 3], [21, 29]],
+                    16: [[0, 3], [21, 23], 81],
+                    17: [[0, 3], [21, 25], 81],
+                    18: [[0, 3], [21, 27]],
+                    19: [[0, 3], [21, 23]],
+                    20: [[0, 2], [21, 22], 81],
+                    32: [0, [21, 33]],
+                    33: [0, [21, 38]],
+                    34: [[0, 1], [22, 37]]
+                },
+                52: {
+                    0: [0],
+                    1: [[0, 3], [11, 15], [21, 23], 81],
+                    2: [[0, 1], 3, [21, 22]],
+                    3: [[0, 3], [21, 30], [81, 82]],
+                    4: [[0, 2], [21, 25]],
+                    5: [[0, 2], [21, 27]],
+                    6: [[0, 3], [21, 28]],
+                    22: [[0, 1], [22, 30]],
+                    23: [[0, 1], [22, 28]],
+                    24: [[0, 1], [22, 28]],
+                    26: [[0, 1], [22, 36]],
+                    27: [[0, 2], [22, 23], [25, 32]]
+                },
+                53: {
+                    0: [0],
+                    1: [[0, 3], [11, 14], [21, 22], [24, 29], 81],
+                    3: [[0, 2], [21, 26], 28, 81],
+                    4: [[0, 2], [21, 28]],
+                    5: [[0, 2], [21, 24]],
+                    6: [[0, 2], [21, 30]],
+                    7: [[0, 2], [21, 24]],
+                    8: [[0, 2], [21, 29]],
+                    9: [[0, 2], [21, 27]],
+                    23: [[0, 1], [22, 29], 31],
+                    25: [[0, 4], [22, 32]],
+                    26: [[0, 1], [21, 28]],
+                    27: [[0, 1], [22, 30]], 28: [[0, 1], [22, 23]],
+                    29: [[0, 1], [22, 32]],
+                    31: [0, [2, 3], [22, 24]],
+                    34: [0, [21, 23]],
+                    33: [0, 21, [23, 25]],
+                    35: [0, [21, 28]]
+                },
+                54: {
+                    0: [0],
+                    1: [[0, 2], [21, 27]],
+                    21: [0, [21, 29], [32, 33]],
+                    22: [0, [21, 29], [31, 33]],
+                    23: [[0, 1], [22, 38]],
+                    24: [0, [21, 31]],
+                    25: [0, [21, 27]],
+                    26: [0, [21, 27]]
+                },
+                61: {
+                    0: [0],
+                    1: [[0, 4], [11, 16], 22, [24, 26]],
+                    2: [[0, 4], 22],
+                    3: [[0, 4], [21, 24], [26, 31]],
+                    4: [[0, 4], [22, 31], 81],
+                    5: [[0, 2], [21, 28], [81, 82]],
+                    6: [[0, 2], [21, 32]],
+                    7: [[0, 2], [21, 30]],
+                    8: [[0, 2], [21, 31]],
+                    9: [[0, 2], [21, 29]],
+                    10: [[0, 2], [21, 26]]
+                },
+                62: {
+                    0: [0],
+                    1: [[0, 5], 11, [21, 23]],
+                    2: [[0, 1]],
+                    3: [[0, 2], 21],
+                    4: [[0, 3], [21, 23]],
+                    5: [[0, 3], [21, 25]],
+                    6: [[0, 2], [21, 23]],
+                    7: [[0, 2], [21, 25]],
+                    8: [[0, 2], [21, 26]],
+                    9: [[0, 2], [21, 24], [81, 82]],
+                    10: [[0, 2], [21, 27]],
+                    11: [[0, 2], [21, 26]],
+                    12: [[0, 2], [21, 28]],
+                    24: [0, 21, [24, 29]],
+                    26: [0, 21, [23, 30]],
+                    29: [[0, 1], [21, 27]],
+                    30: [[0, 1], [21, 27]]
+                },
+                63: {
+                    0: [0],
+                    1: [[0, 5], [21, 23]],
+                    2: [0, 2, [21, 25]],
+                    21: [0, [21, 23], [26, 28]],
+                    22: [0, [21, 24]],
+                    23: [0, [21, 24]],
+                    25: [0, [21, 25]],
+                    26: [0, [21, 26]],
+                    27: [[0, 1], [21, 26]],
+                    28: [[0, 2], [21, 23]]
+                },
+                64: {
+                    0: [0],
+                    1: [[0, 1], [4, 6], [21, 22], 81],
+                    2: [[0, 3], 5, [21, 23]],
+                    3: [[0, 3], [21, 24], 81],
+                    4: [[0, 2], [21, 25]],
+                    5: [[0, 2], [21, 22]]
+                },
+                65: {
+                    0: [0],
+                    1: [[0, 9], 21],
+                    2: [[0, 5]],
+                    21: [[0, 1], [22, 23]],
+                    22: [[0, 1], [22, 23]],
+                    23: [[0, 3], [23, 25], [27, 28]],
+                    28: [[0, 1], [22, 29]],
+                    29: [[0, 1], [22, 29]],
+                    30: [[0, 1], [22, 24]], 31: [[0, 1], [21, 31]],
+                    32: [[0, 1], [21, 27]],
+                    40: [0, [2, 3], [21, 28]],
+                    42: [[0, 2], 21, [23, 26]],
+                    43: [[0, 1], [21, 26]],
+                    90: [[0, 4]], 27: [[0, 2], [22, 23]]
+                },
+                71: { 0: [0] },
+                81: { 0: [0] },
+                82: { 0: [0] }
+            };
             
             
             var provincial  = parseInt(value.substr(0, 2), 10),
             var provincial  = parseInt(value.substr(0, 2), 10),
                 prefectural = parseInt(value.substr(2, 2), 10),
                 prefectural = parseInt(value.substr(2, 2), 10),
                 county      = parseInt(value.substr(4, 2), 10);
                 county      = parseInt(value.substr(4, 2), 10);
             
             
-            if (!china_admin_div_codes[provincial]) { return false; }
-            if (!china_admin_div_codes[provincial][prefectural]) { return false; }
-            var in_range = false, range_def = china_admin_div_codes[provincial][prefectural];
-            for (var i=0; i<range_def.length; i++) {
-                if (range_def[i] instanceof Array) {
-                    if (range_def[i][0] <= county && county <= range_def[i][1]) 
-                        { in_range = true; break; }
-                } else {
-                    if (county == range_def[i]) { in_range = true; break; }
+            if (!adminDivisionCodes[provincial] || !adminDivisionCodes[provincial][prefectural]) {
+                return false;
+            }
+            var inRange  = false,
+                rangeDef = adminDivisionCodes[provincial][prefectural];
+            for (var i = 0; i < rangeDef.length; i++) {
+                if (($.isArray(rangeDef[i]) && rangeDef[i][0] <= county && county <= rangeDef[i][1])
+                    || (!$.isArray(rangeDef[i]) && county === rangeDef[i]))
+                {
+                    inRange = true;
+                    break;
                 }
                 }
             }
             }
-            if (!in_range) { return false; }
+
+            if (!inRange) {
+                return false;
+            }
             
             
             // Check date of birth
             // Check date of birth
-            var dateofbirth_str;
-            if (value.length == 18) {
-                dateofbirth_str = value.substr(6, 8);
+            var dob;
+            if (value.length === 18) {
+                dob = value.substr(6, 8);
             } else /* length == 15 */ { 
             } else /* length == 15 */ { 
-                dateofbirth_str = "19" + value.substr(6, 6);
+                dob = '19' + value.substr(6, 6);
+            }
+            var year  = parseInt(dob.substr(0, 4), 10),
+                month = parseInt(dob.substr(4, 2), 10),
+                day   = parseInt(dob.substr(6, 2), 10);
+            if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) {
+                return false;
             }
             }
-            var year  = parseInt(dateofbirth_str.substr(0, 4), 10),
-                month = parseInt(dateofbirth_str.substr(4, 2), 10),
-                day   = parseInt(dateofbirth_str.substr(6, 2), 10);
-            if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) { return false; }
-            
-            // Check order code
-            ; // Already checked by regex. No code here. 
             
             
             // Check checksum (18-digit system only)
             // Check checksum (18-digit system only)
-            if (value.length == 18) {
-                var sum    = 0, 
+            if (value.length === 18) {
+                var sum    = 0,
                     weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
                     weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
-                for (var i=0; i<17; i++) {
+                for (i = 0; i < 17; i++) {
                     sum += parseInt(value.charAt(i), 10) * weight[i];
                     sum += parseInt(value.charAt(i), 10) * weight[i];
                 }
                 }
-                var correct_checksum = (12 - (sum % 11)) % 11;
-                var provided_checksum;
-                if (value.charAt(18-1).toUpperCase() != 'X') {
-                    provided_checksum = parseInt(value.charAt(18-1), 10);
-                } else { provided_checksum = 10; }
-                
-                if (provided_checksum != correct_checksum) { return false; }
+                sum = (12 - (sum % 11)) % 11;
+                var checksum = (value.charAt(17).toUpperCase() !== 'X') ? parseInt(value.charAt(17), 10) : 10;
+                return checksum === sum;
             }
             }
             
             
-            // All rules passed
             return true;
             return true;
-            
-            // End of validation to citizen identification number of China
         },
         },
         
         
         /**
         /**

+ 24 - 0
test/spec.js

@@ -3495,6 +3495,7 @@ describe('id', function() {
                         '<option value="BR">Brazil</option>',
                         '<option value="BR">Brazil</option>',
                         '<option value="CH">Switzerland</option>',
                         '<option value="CH">Switzerland</option>',
                         '<option value="CL">Chile</option>',
                         '<option value="CL">Chile</option>',
+                        '<option value="CN">China</option>',
                         '<option value="CZ">Czech</option>',
                         '<option value="CZ">Czech</option>',
                         '<option value="DK">Denmark</option>',
                         '<option value="DK">Denmark</option>',
                         '<option value="EE">Estonia</option>',
                         '<option value="EE">Estonia</option>',
@@ -3625,6 +3626,29 @@ describe('id', function() {
         }
         }
     });
     });
 
 
+    // #793
+    it('Chinese citizen identification number', function() {
+        this.bv.updateOption('id', 'id', 'country', 'CN');
+
+        // Valid samples
+        var validSamples = ['450202201409072332', '22011219930407001X', '110108601017023'];
+        for (var i in validSamples) {
+            this.bv.resetForm();
+            this.$id.val(validSamples[i]);
+            this.bv.validate();
+            expect(this.bv.isValid()).toBeTruthy();
+        }
+
+        // Invalid samples
+        var invalidSamples = ['999999199304070016', '220112190002290016', '220112199304070019', '999999601017023', '110108999999023'];
+        for (i in invalidSamples) {
+            this.bv.resetForm();
+            this.$id.val(invalidSamples[i]);
+            this.bv.validate();
+            expect(this.bv.isValid()).toEqual(false);
+        }
+    });
+
     it('Czech national identification number (RC)', function() {
     it('Czech national identification number (RC)', function() {
         this.bv.updateOption('id', 'id', 'country', 'CZ');
         this.bv.updateOption('id', 'id', 'country', 'CZ');
 
 

+ 24 - 0
test/spec/validator/id.js

@@ -9,6 +9,7 @@ describe('id', function() {
                         '<option value="BR">Brazil</option>',
                         '<option value="BR">Brazil</option>',
                         '<option value="CH">Switzerland</option>',
                         '<option value="CH">Switzerland</option>',
                         '<option value="CL">Chile</option>',
                         '<option value="CL">Chile</option>',
+                        '<option value="CN">China</option>',
                         '<option value="CZ">Czech</option>',
                         '<option value="CZ">Czech</option>',
                         '<option value="DK">Denmark</option>',
                         '<option value="DK">Denmark</option>',
                         '<option value="EE">Estonia</option>',
                         '<option value="EE">Estonia</option>',
@@ -139,6 +140,29 @@ describe('id', function() {
         }
         }
     });
     });
 
 
+    // #793
+    it('Chinese citizen identification number', function() {
+        this.bv.updateOption('id', 'id', 'country', 'CN');
+
+        // Valid samples
+        var validSamples = ['450202201409072332', '22011219930407001X', '110108601017023'];
+        for (var i in validSamples) {
+            this.bv.resetForm();
+            this.$id.val(validSamples[i]);
+            this.bv.validate();
+            expect(this.bv.isValid()).toBeTruthy();
+        }
+
+        // Invalid samples
+        var invalidSamples = ['999999199304070016', '220112190002290016', '220112199304070019', '999999601017023', '110108999999023'];
+        for (i in invalidSamples) {
+            this.bv.resetForm();
+            this.$id.val(invalidSamples[i]);
+            this.bv.validate();
+            expect(this.bv.isValid()).toEqual(false);
+        }
+    });
+
     it('Czech national identification number (RC)', function() {
     it('Czech national identification number (RC)', function() {
         this.bv.updateOption('id', 'id', 'country', 'CZ');
         this.bv.updateOption('id', 'id', 'country', 'CZ');