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 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.
- possible duplicates: stackoverflow./questions/2386054, stackoverflow./questions/5286046 – Bergi Commented Dec 26, 2011 at 17:06
4 Answers
Reset to default 10I'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/jfriend00/K9bjL/
Something like this should work:
/\+?[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}$/