You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mick Knutson <mi...@hotmail.com> on 2003/10/02 15:42:43 UTC

[OT] International telephone number formatter component????

I am wondering if anyone has developed an International telephone number
formatter component?
I have International users, creating phone numbers that will be used to
generate emergency phone calls by a software package. So having the proper
International number is essential.
Just thought it might have already been done.

---
Thanks
Mick Knutson

+001(805) 563-0666 Office
+001 (708) 570-2772 Fax
---

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [OT] International telephone number formatter component????

Posted by Greg Ludington <gl...@san.rr.com>.
>
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.
<

You may be able to accomplish what you want using localized forms and
the mask rule in the validator.  Assuming that your default
language/country is en_US (a parochial assumption, I know), your
validation.xml might contain bits like the following:

<formset>
  <form name="userInfo">
    <field property="telephone" depends="mask">
      <var>
        <var-name>mask</var-value>
        <var-value>^\(?(\d{3})\)?[-| ]?(\d{3})[-| ]?(\d{4})$</var-value>
      </var>
    </field>
  </form>
</formset>

<formset language="en" country="GB">
  <form name="userInfo">
    <field property="telephone" depends="mask">
      <var>
        <var-name>mask</var-value>
        <var-value>--a regexp for British phone numbers -- sorry, never
been :)--</var-value>
      </var>
    </field>
  </form>
</formset>

...and so on for each language/country.  Your researchers would have to
provide you the masks for each country, and, as you add counties, you
would add their formsets to validation.xml.  A standalone validation
rule might be more convenient, but this sort of approach might do the
job for you.  The struts-validator example webapp has a couple of sample
forms that perform locale-specific validations.

-Greg



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [OT] International telephone number formatter component????

Posted by Steve Raeburn <sr...@apache.org>.
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:mickknutson@hotmail.com]
> 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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [OT] International telephone number formatter component????

Posted by Mick Knutson <mi...@hotmail.com>.
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
---

----- Original Message ----- 
From: "Joe Germuska" <Jo...@Germuska.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, October 02, 2003 6:54 AM
Subject: Re: [OT] International telephone number formatter component????


> At 6:42 -0700 10/2/03, Mick Knutson wrote:
> >I am wondering if anyone has developed an International telephone number
> >formatter component?
> >I have International users, creating phone numbers that will be used to
> >generate emergency phone calls by a software package. So having the
proper
> >International number is essential.
> >Just thought it might have already been done.
>
> It's actually a very thorny problem, as in some countries, phone
> numbers don't even have a consistent number of digits, nor a common
> format.  So it's as much a research problem as a coding problem.  I
> took a stab at it a few years ago, but once I realized that the scope
> of the problem outweighed my immediate needs, I left it aside.
>
> I'd love to hear if anyone has such a thing...
>
> Joe
>
> -- 
> Joe Germuska
> Joe@Germuska.com
> http://blog.germuska.com
>   "We want beef in dessert if we can get it there."
>    -- Betty Hogan, Director of New Product Development, National
> Cattlemen's Beef Association
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [OT] International telephone number formatter component????

Posted by Joe Germuska <Jo...@Germuska.com>.
At 6:42 -0700 10/2/03, Mick Knutson wrote:
>I am wondering if anyone has developed an International telephone number
>formatter component?
>I have International users, creating phone numbers that will be used to
>generate emergency phone calls by a software package. So having the proper
>International number is essential.
>Just thought it might have already been done.

It's actually a very thorny problem, as in some countries, phone 
numbers don't even have a consistent number of digits, nor a common 
format.  So it's as much a research problem as a coding problem.  I 
took a stab at it a few years ago, but once I realized that the scope 
of the problem outweighed my immediate needs, I left it aside.

I'd love to hear if anyone has such a thing...

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
  "We want beef in dessert if we can get it there."
   -- Betty Hogan, Director of New Product Development, National 
Cattlemen's Beef Association


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org