Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate Indian Phone number with optional +91 or 0 preceeding 10 digits

I am using following reg expression to validate Indian phone number. I want optional +91 or 0 before 10 digits of phone. How can I do it?

^[789]\d{9}$
like image 804
ubaid ashraf Avatar asked May 26 '13 10:05

ubaid ashraf


People also ask

How do I validate a 10 digit mobile number?

you can also use jquery for this length==10){ var validate = true; } else { alert('Please put 10 digit mobile number'); var validate = false; } } else { alert('Not a valid number'); var validate = false; } if(validate){ //number is equal to 10 digit or number is not string enter code here... } Save this answer.

How can I check a mobile number is valid in India?

Mobile Number validation criteria:The first digit should contain numbers between 6 to 9. The rest 9 digit can contain any number between 0 to 9. The mobile number can have 11 digits also by including 0 at the starting. The mobile number can be of 12 digits also by including 91 at the starting.

How do I validate a phone number with a country code?

How do I validate a country phone number? EPP-style phone numbers use the format + CCC . NNNNNNNNNN x EEEE , where C is the 1–3 digit country code, N is up to 14 digits, and E is the (optional) extension. The leading plus sign and the dot following the country code are required.

How do I validate a phone number in Google forms?

On Google Forms, we'll create a new form, providing a name and description. Then, we'll add the 2 fields we need to our form: name and phone number. The field type for both will be Short answer. That's all there is to it.


2 Answers

You can use ^([0]|\+91)?\d{10} as starts with 0 or +91 and 10 digits after that.

..but as you must have seen number starts with 7,8 or 9

Then, you should use ^([0]|\+91)?[789]\d{9}$ which means starts with 7, 8 or 9 and follows 9 digits after that.

Some random matches;

+919802422462
08150166859
like image 152
Soner Gönül Avatar answered Nov 15 '22 17:11

Soner Gönül


This should do

^(0|\+91)?[789]\d{9}$

? matches preceding character or group optionally..

like image 24
Anirudha Avatar answered Nov 15 '22 16:11

Anirudha