jQuery通过igorescobar jQuery掩码插件验证电话号码输入。
I'm using the Jquery Mask plugin to validate a phone text input like so: http://igorescobar.github.io/jQuery-Mask-Plugin/
我使用Jquery Mask插件来验证手机文本输入,比如:http://igorescobar.github.io/jquerymask - plugin/。
$('#phone').mask('(999) 999-9999');
How can I use a regex expression to validate this phone number format?
如何使用regex表达式验证此电话号码格式?
Thank you!
谢谢你!
1 个解决方案
#1
3
Maybe something like that? (I'm not sure of the syntax, so correct me if I'm wrong)
也许这样的?(我不太清楚语法,如果我错了,请纠正我)
function checkPhoneNumber(num) {
var regexp = /\([0-9]{3}\)\s[0-9]{3}-[0-9]{4}/;
var valid = regexp.test(num);
return valid;
}
\(
This is for an opening bracket;
(这是一个开口托架;
[0-9]{3}
This is for digits from 0
through 9
occurring only 3 times;
[0-9]{3}这是指从0到9的数字只发生3次;
\)
This is for a closing bracket;
\)这是为关闭括号;
\s
This is for a white space character;
这是一个空白字符;
-
This is for the dash
-这是破折号。
[0-9]{4}
This is for digits from 0
through 9
occurring only 4 times;
[0-9]{4}这是指从0到9的数字只发生4次;
更多相关文章
- 一旦db通过Node.js发生更新,就立即推送数据
- HTML CSS Javascript中 id重复时会发生的 情况
- linux系统启动过程详解-开机加电后发生了什么 --linux内核剖析(零
- 连接SQLServer时提示“但是在登录前的握手期间发生错误。 (provi
- 使用进度条延迟加载图像会使图像在显示时发生损坏
- 与adb的连接已关闭,并且发生了严重错误[重复]
- 将列添加到表时可能发生的冲突
- 在android上滚动时,列表视图的位置会发生变化