验证电话号码 [英] validation for phone number
问题描述
我需要验证电话号码才能接受12位数字并且它应该接受空格而且电话号码不应该以数字1开头
这里是我试过的验证,但在这里它根本不接受1位数。在我的情况下1不应该从第一个开始就是它怎么办?
var phonepat = / ^ [\(()+ - ] *([02-9] [\(()+ - ] *){7,12} $ /;
i need validation for phone number to accept only 12 digits and it should accept spaces and phonenumber should not start with digit 1
here is the validation i tried but here its not at all accepting 1 digit .in my case 1 should not start from first that's it.how to do?
var phonepat=/^[\s()+-]*([02-9][\s()+-]*){7,12}$/;
推荐答案
/;
尝试:
Try:
^[023456789](\d|\s){11}
如果您打算使用正则表达式,请获取 Expresso 的副本[ ^ ] - 它是免费的,它会检查并生成正则表达式。
If you are going to be playing with regular expressions, get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.
这篇关于验证电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!