Home > Web Front-end > JS Tutorial > body text

How jQuery uses regular expressions to verify mobile phone number, ID number, and Chinese name

高洛峰
Release: 2016-12-26 16:52:10
Original
1419 people have browsed it

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); }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!