cgcmq
asked on
Regular Expression - international telephone format
I have an ASP.net form in which I need to validate an input field for either a North American or international telephone number.
For the North American format I have:
ValidationExpression="\d{3 }-\d{3}-\d {4}"
How can this be altered so that it accepts either the NA or the international telephone formats?
For the North American format I have:
ValidationExpression="\d{3
How can this be altered so that it accepts either the NA or the international telephone formats?
Umm, I am not an expert on an internal telephone formats, but how can there be any? The reason I say this is because each country has a different scheming. For example, I am originally from a country that uses a two digit city code, along with 7 digit phone numbers. But, there are cities in my native place that have 6 digit numbers.
Clearly, this does not follow the pattern we have in North America (where I am right now).
I believe each country has its own schemes and you cannot generalize an international telephone format, UNLESS THERE IS SUCH A STANDARD ???? I did a search on google for this but it did not reveal that there is such a format, so if there is let me know.
You would have to study each country's telephone format and create a regular expression for that.
Clearly, this does not follow the pattern we have in North America (where I am right now).
I believe each country has its own schemes and you cannot generalize an international telephone format, UNLESS THERE IS SUCH A STANDARD ???? I did a search on google for this but it did not reveal that there is such a format, so if there is let me know.
You would have to study each country's telephone format and create a regular expression for that.
ASKER
I found this:
((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?) )(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext )\d{1,5}){0,1}$
at http://javascript.about.com/library/blre.htm which seems pretty flexible.
((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?)
at http://javascript.about.com/library/blre.htm which seems pretty flexible.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
the international prefix for north america is +1