Disclaimer: The following represents my personal experience - I'm not a
phone number expert :-)

As an example of the problem, the Oftel website (www.oftel.gov.uk) lists the
following *recommended* formats for the UK:

Fixed line phone number:
    * (01XX) XXX XXXX
    * (01XXX) XXXXXX
    * (01XXXX) XXXXX
    * (02X) XXXX XXXX

07 (mobile) number
    * 07XX XXXXXXX or 07XXX XXXXXX.

08 (freephone, Lo-call or National Rate) number
    * 08XX XXXXXXX or 08XXX XXXXXX.

09 (PRS) number
    * 09XX XXXXXXX or 09XXX XXXXXX.
    * 09XX XXXXXXX or 09XXX XXXXXX.

Since you're probably only interested in fixed and cell phone numbers that
cuts it down to a mere six different formats for the UK alone. At least
until they change the codes again :-)

I think the only thing you can guarantee about phone numbers is that if you
ignore the formatting entirely and just dial the digits, you'll probably get
through. Unless of course, a UK user has included the international dialling
code and entered the number like + 44 (01XXX) XXXXXX. In this case, you need
to dial your local international access code, then 44 for the UK, then DROP
the zero, then dial the rest of the number!

If you were in the UK trying to dial a US number entered as (picking a
random example ;-) ) +001(805) 563-0666, you might incorrectly dial 00 001
805 563 0666 (international access code from the UK is 00).

An alternative approach to attempting to validate a single telephone number
field would be to split it into separate input fields e.g.
 - Country code : 44
 - Area code: 01XXXX
 - Local number : XXXXXX
 - Extension: XXXX

(note: this 'area code' doesn't always represent a geographical area. UK
cell phone numbers, for instance, are national, with the code denoting the
provider.)

I'd store the 'numbers' as Strings to ensure you retain whatever format your
users are comfortable with (after all it is *their* number) and strip out
the formatting when you need to use it.

That still leaves you with the leading 0 problem (or whatever the rules are
for other countries). I can only suggest that you would need to be able to
look up the rules for each country and strip off any unnecessary digits
based on a rule. You might be able to do this during input validation and
warn the user, but to avoid confusing/infuriating the user I think I would
just accept whatever they gave me and handle it intelligently when I need to
use it.

Telephone numbers are as personal and varied as postal codes and I just
*hate* it when some site tells me my house doesn't exist because their rules
can't handle my post code.

Good luck!

Steve



> -----Original Message-----
> From: Mick Knutson [mailto:[EMAIL PROTECTED]
> Sent: October 2, 2003 7:03 AM
> To: Struts Users Mailing List
> Subject: Re: [OT] International telephone number formatter component????
>
>
> I do not disagree about the research part at all. I know it will take a
> researcher on my staff a great deal of time to maintain, but it
> is never the
> less, a needed feature.
> I just thought that most Countries have a fairly well formatted
> number. And
> mostly I am taking about supporting N.&S. America, Western Europe only.
> Later look at the far East.
>
> But this would need to choose the whole part of the phone number then just
> store the proper number into my DB for the user. Until they update the
> number again, then they choose again.
>
> ---
> Thanks
> Mick Knutson
>
> +001(805) 563-0666 Office
> +001 (708) 570-2772 Fax
> ---



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to