本文介绍了jquery验证电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想验证电话号码,如(123)456-7890或1234567890 如何在以下代码中写入'匹配'条件?
I want to validate phone numbers like (123) 456-7890 or 1234567890 How should be the 'matches' condition be written in the following code?
form.validate({ rules: { phoneNumber: {matches:"[0-9]+",minlength:10, maxlength:10}推荐答案
你的正则表达式应该是类似
Your regex should be something like
[0-9 \-\(\)\ s] + 。
它匹配数字,破折号,括号和空格。
It matches numbers, dashes, parentheses and space.
如果你需要更严格的东西,只需匹配你的例子,试试这个:
If you need something more strict, matching just your example, try this:
([0-9] {10})|(\([0-9] {3} \ )\ + + [0-9] {3} \- [0-9] {4})
更多推荐
jquery验证电话号码
发布评论