Home >Web Front-end >JS Tutorial >How jQuery uses regular expressions to verify mobile phone number, ID number, and Chinese name
Number judgment method: isNaN() function
test() method judges whether the regular expression content is matched in the string, and returns a boolean value (true / false)
// 验证中文名称 function isChinaName(name) { var pattern = /^[\u4E00-\u9FA5]{1,6}$/; return pattern.test(name); } // 验证手机号 function isPhoneNo(phone) { var pattern = /^1[34578]\d{9}$/; return pattern.test(phone); } // 验证身份证 function isCardNo(card) { var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; return pattern.test(card); }
The above is the knowledge that the editor introduced to you on how jQuery uses regular expressions to verify mobile phone numbers, ID numbers, and Chinese names. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to everyone in time. I would also like to thank you all for your support of the PHP Chinese website
For more articles on how jQuery uses regular expressions to verify mobile phone numbers, ID numbers, and Chinese names, please pay attention to the PHP Chinese website!