简体   繁体   中英

Mobile or phone number validation in javascript

I need to validate phone or mobile number in javascript.
It should match the following types:
+91-9198387083
9198387083
09198387083
It is a 10 digit number with one of these four prefixes '+91-' , '+91' , '0' or ''
Can someone suggest me a regex expression in javascript which matches all the three types.

I'd using something like this:

/^(\+91-|\+91|0)?\d{10}$/

This is very specific about one of your three allowable prefixes (or no prefix) followed by exactly 10 digits and no extra characters on the beginning of end of the string.

Test app with both valid and invalid phone numbers here: http://jsfiddle.net/jfriend00/K9bjL/

这样的事情应该起作用:

/\\+?[0-9]+-?[0-9]/

10 digit number with one of these four prefixes +91- , +91 , 0 or :

/(\+91-?|0)?\d{10}/
+7 (123) 45-67-890
8(123)381-198-2
and etc.

My simply mask for all of similar phones

/^[+]?(\d[^\d]*){11}$/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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