JS authentication name and ID number

Source: Internet
Author: User

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 varRegname =/^[\u4e00-\u9fa5]{2,4}$/; 2 if(!regname.test (name)) { 3Alert (' real name is wrong '); 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 varRegidno =/(^\d{15}$) | (^\d{18}$) | (^\d{17} (\d| X|X) $)/; 2 if(!regidno.test (Idno)) { 3Alert (' ID number is incorrect '); 4     return false; 5}

Reference link:http://www.cnblogs.com/songhaipeng/archive/2012/12/27/2835030.html

JS authentication name and 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.