[英]Australian Mobile number regular expression validation needs to allow space in between number
I need to validate the mobile number 我需要验证手机号码
my input field is below 我的输入字段如下
<form name="uploadForm">
<input type="tel" name="MobileNumber" id="MobileNumber" data-ng-model="ApplicationData.MobileNumber" required maxlength="14" data-ng-pattern="/^(0?4[0-9]{8}/\s)$/">
<span data-ng-show="uploadForm.MobileNumber.$error.pattern">Please enter a valid mobile number.</span>
<input type="tel" name="Number" id="Number" data-ng-model="ApplicationData.Number" required maxlength="14" data-ng-pattern="/(^1300\d{6}$)|(^1800\d{6}$)|(^0[2|3|7|8]{1}[0-9]{8}$)|(^04\d{2,3}\d{6}$)/">
<span data-ng-show="uploadForm.Number.$error.pattern">Please enter a valid mobile number.</span>
</form>
any one can you help me please ? 有人可以帮我吗?
I think for your first question replace with this regexp. 我认为您的第一个问题是用此正则表达式替换。 it accepts space in between number.
它接受数字之间的空格。
ng-pattern="/^04(\s?[0-9]{2}\s?)([0-9]{3}\s?[0-9]{3}|[0-9]{2}\s?[0-9]{2}\s?[0-9]{2})$/"
for your second question, its quite long this is what i can come up with at this moment. 对于您的第二个问题,这是我目前能想到的很长的时间。
ng-pattern="/(^1300\s?([0-9]{3}\s?[0-9]{3}|[0-9]{2}\s?[0-9]{2}\s?[0-9]{2})$)|(^1800\s?([0-9]{3}\s?[0-9]{3}|[0-9]{2}\s?[0-9]{2}\s?[0-9]{2})$)|(^0[2|3|7|8]{1}[0-9]{8}$)|(^04(\s?[0-9]{2}\s?)([0-9]{3}\s?[0-9]{3}|[0-9]{2}\s?[0-9]{2}\s?[0-9]{2})$)/"
any body have interest to modify/short this one. 任何机构都有兴趣修改/缩短此内容。
If I understand this correctly, this is your regex pattern. 如果我正确理解这一点,这就是您的正则表达式模式。
^04[0-9]{8}$
^04
- starts with 04 ^04
从04开始
[0-9]{8}
- matches the next 8 digits [0-9]{8}
-匹配接下来的8位数字
$
- matches end of string $
-匹配字符串的结尾
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.