When the user registration information will be used to modify or regular expressions to determine the ID number, you can directly call the function
1 // Analyzing ID number 2 function idCardFn (idCard) { . 3 var REG = / ^ \ D { . 6 } ( 18 is | . 19 | 20 is ?) \ D { 2 } ( 0 [ . 19 ] | 1 [ 12 is ] ) ( 0 [ . 1 - . 9 ] | [ 12 is ] \ D | . 3 [ 01 ]) \ D { . 3 } (\ D | X-) $ / I; . 4 IF (! reg.test (idCard)) { . 5 Layer. MSG ( 'Incorrect identification number format ' ); . 6 the console.log ( ' ID number error ' , idCard); . 7 return to false ; . 8 } the else { . 9 the console.log ( ' ID number is correct ' , idCard); 10 } . 11 }
idCardFn (idCard); // can be called directly