The interface used in recent projects requires calling real-name authentication. The price of real-name authentication interface is not a few cents higher than that of SMS. Therefore, the conditions for calling real-name authentication must be strictly controlled, so JS is used to verify the real name and JS is used to verify the ID number.
Go to the main topic
1.js verify the real name
JS verification of real names is used to match unicode characters, while Chinese names are generally 2-4, so the match is repeated {2,4} times
var regName =/^[/u4e00-/u9fa5]{2,4}$/; if(!regName.test(name)){ alert('The real name is filled in incorrectly'); return false; }2.js verification of ID number
js verification ID number, Chinese ID number, first generation ID number is a 15-digit number, second generation ID number is all 18-digit, and the last check digit may be 'X' or 'x', so there are four possibilities: a.15-digit number b.18-digit number c.17-digit number, the eighteenth digit is 'X' d.17-digit number, and the eighteenth digit is 'x'
var regIdNo = /(^/d{15}$)|(^/d{18}$)|(^/d{17}(/d|X|x)$)/; if(!regIdNo.test(idNo)){ alert('Is ID number filled in incorrectly'); return false; }Detailed version of ID card verification:
//www.VeVB.COM/article/88771.htm
3.js verification of mobile phone number
Except for the area code (+86), the mobile phone numbers in China are all 11 digits and the first letter must be 1, and the second digit may not be 1, but so far, there are no 1 and 2.
var mobileRegex = /^(((1[3456789][0-9]{1})|(15[0-9]{1}))+/d{8})$/; if(mobileRegex.test(phone)){ alert('MobileRegex.test(phone)){ alert('MobileRegex correct'); }else{ alert('MobileRegex incorrectly entered'); }The above article JS verification of real name and ID number and a simple example of mobile phone number is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.