[tpm] Regex to validate (international) phone numbers
Alex Beamish
talexb at gmail.com
Wed Aug 1 10:27:34 PDT 2007
On 7/31/07, Madison Kelly <mkelly at alteeve.com> wrote:
> [..]
> How might I go about checking telephone numbers from both NA and
> international?
Hi Madison,
How rigorous does this test have to be? Once you've answered that question,
then you can move towards a solution.
If the answer is 'not that rigorous', I'd suggest you ask for the phone
number in an International format, which is
+ $countryCode $everythingElse
Since North America is where the phone was developed, we get the #1 country
code, and everything else is a three digit area code and a seven digit
number. Other country's numbers vary, even within countries, I think.
Or you can go the other route and follow E.164 (
http://en.wikipedia.org/wiki/E.164). That's useful, actually, as it limits a
phone number to 15 digits.
So as long as the phone number string consists of just numbers, spaces,
hyphens and perhaps a leading '+', and as long as there are no more than 15
digits, I'd say it passes.
--
Alex Beamish
Toronto, Ontario
aka talexb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/toronto-pm/attachments/20070801/a2f5d633/attachment.html
More information about the toronto-pm
mailing list