Recent projects with the need to call the real-name authentication interface, real-name authentication interface price is not a few cents higher than the text message, so call the real-names authentication conditions to strictly check, so the use of JS to verify the real title and JS Authentication ID number.
Go to the Chase
JS to verify the real name, is to use the Unicode character to match, and the Chinese name length is generally 2-4, so repeat the match {2,4} times
1.js Verify real name
1 var regname =/^[\u4e00-\u9fa5]{2,4}$/; 2 if (! regname.test (name)) {3 alert (' real name is incorrect '); 4 return false ; 5 }
JS Authentication ID number, China's ID number, a generation of identity card number is 15 digits, the second-generation ID card is 18-bit, the last check digit in addition to may be the number may also be ' x ' or ' x ', so there are four possibilities: a.15 bit number b.18 digit c.17 digit, 18th bit is ' X ' d.17 digits, the 18th digit is ' x '
2.js Authentication ID Number
1 var regidno =/(^\d{15}$) | (^\d{18}$) | (^\d{17} (\d| X|X) $)/; 2 if (! regidno.test (Idno)) {3 alert (' ID number is incorrect '); 4 return false ; 5 }
JS verify real name and ID number