At 9/26/01 12:48 PM, Michael Brody wrote:


>The following 3 lines of code will catch all phone numbers that are not
>international format and convert them.
>
>
>
>if (substr($in{owner_phone},0,3) ne "+1."){
>$in{owner_phone} = "+1." . "$in{owner_phone}";
>}

Unfortunately, that does not lead to correct behavior. For example, given 
this valid UK telephone number:

  +44.1332999999

It converts it to:

  +1.+44.1332999999

...which is clearly incorrect.

However, this is a good indication of why OpenSRS should come up with a 
better system: resellers unfamiliar with telephone country codes will do 
things like this and you'll end up with invalid data in the fields. The 
restrictive effort to validate it will make things worse than if it was 
just left as free text.

As I said, you can't convert arbitrary, free-text phone number input to a 
fixed representation in code. It's just not possible. Anyone who thinks 
it is should explain how you'd convert the following input:

   855 555 1212

This can be either:

  +1.8555551212  (phone number in the US)
  +855.5551212  (phone number in Cambodia)

Regarding your other post:

>sorry forgot.  to make sure there are no () or - to screw things up you
>can:
>
> if ($in{owner_phone} !~ /^[+.0-9]+$/){
>error_out ("The Owner Phone number can only contain numbers");
>
>}

But my point was that restricting it to certain characters, then 
rejecting anything that doesn't match, is a bad idea. Asking people to 
enter phone numbers in a non-standard format they've never heard of, then 
giving them a free-text entry field to do so, is about as close as you 
can get to forcing people to make mistakes.

North American users in particular, who have enjoyed a fixed-format 
telephone number representation for over 40 years, will NOT instantly 
grasp that they should put "+1." in front of their phone number, then 
leave out spaces, brackets, hyphens, and "ext" -- even if told to do so. 
It's just counter-intuitive; it sounds like the directions must be wrong.

--
Robert L Mathews, Tiger Technologies

Put an animated US flag on your Windows desktop: http://deskflag.com/

Reply via email to