I have following input for accepting mobile number. But I think it will not work world wide. It will work for Indian mobile numbers only.(e.g. +910123456789)(+91 country code for India, 0 to 9 mobile number in India)

How to make it global using pattern=" \+ [] {}"?
I want extension of country so I have added +. How to make it work?

<input type="tel"   size="40"  name="phone" placeholder="Mobile: +911234567890" pattern="\+[0-9]{12,12}" autocomplete="off"  required/>

Recommended Answers

All 5 Replies

Can you show examples of phone numbers you want to match?

I don't know the exact phone number digit range for each country. But in my code, which is working for Indian phone numbers, range is 10 digits.
e.g. +91 0123456789

How to make changes to accept phone numbers world wide? I want to make it available for all countries.

How to make changes to accept phone numbers world wide?

First figure out what the possible ranges are. Then you can just adjust the {12,12} part.

I have all country codes, {12,12} this works fine for Indian numbers. But how to set it for 3 or 4 digit country codes?

Czech Republic:- 420, Bermuda:-1 441

All countries have different mobile number digit range, where can I find all exact ranges? I found all country codes easily, but mobile number range is little confusing, how to find exact ranges?

Or simply what range should I set for {12,12} to accept all numbers?

Now I have this pattern pattern="\+\d{2}\ \d{3}\ \d{10}" will this work world wide?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.