简体   繁体   English

使用正则表达式验证javascript中手机号码的国家/地区代码

[英]Regular Expression to validate the Country code of mobile number in javascript

I need a regular expression that will test the input 我需要一个正则表达式来测试输入

  1. Should start with only one + symbol or optional ( + should not come in between ) 应该仅以一个+符号或可选符号(+不应介于两者之间)开头
  2. should not contain alphabets and any other special character 不应包含字母和任何其他特殊字符
  3. Should not contain consecutive + symbols 不应包含连续的+符号

eg 例如

  • +91 (valid) +91(有效)
  • 91 (valid) 91(有效)
  • ++91 (invalid) ++ 91(无效)
  • +9+1 (invalid) + 9 + 1(无效)
  • 91+ (invalid) 91+(无效)
  • +91&*& (invalid) +91&*&(无效)

Need your inputs on this . 需要您的投入。 Thanks 谢谢

以加号(或不加号)开头,至少1位数字。

^\+?\d+$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM