[英]JavaScript validation for mobile phone number that will allow the user to start the number with a specific combinations
I have been asked to build a landing page with autoresponder SMS and therefore, need the validation to be very strict. 我被要求用自动回复短信建立一个登陆页面,因此,需要非常严格的验证。 Unfortunately I`m not a JavaScript expert. 不幸的是我不是JavaScript专家。
The number should be limited to 7 digits and it should begin with a few certain combinations only, the combinations are as follows: 该数字应限制为7位,并且只能以一些特定的组合开头,组合如下:
050, 044, 066, 099, 073
You could use a regex like this: 您可以使用以下正则表达式:
(050|044|066|099|073)\d{5}
Matches one of the three digit combinations you specified and then 5 more digits. 匹配您指定的三个数字组合之一,然后匹配另外五个数字。
If you want it to tolerate spaces, dashes, brackets and such, then you need to specify that in your question. 如果您希望它可以容忍空格,破折号,方括号等,那么您需要在问题中指定。
There are a ton of other patterns out there that might match your requirement with a little adjustment. 有很多其他模式可能需要稍作调整即可满足您的要求。 See here for example. 例如参见这里 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.