Re: [PHP] validate phone numbers

2001-06-20 Thread Steve Werby

Richard Kurth [EMAIL PROTECTED] wrote:
 I am using this script to validate for phone numbers and it work just
 perfect for US phone numbers. But it rejects some European and
 Australian numbers what do I need to do to make it validate all phone
 numbers

 if (($WPHONE_NO) || ($wphone_no)) {
$wphone_no = trim($wphone_no);
if ($WPHONE_NO)
   $phone_no = trim($WPHONE_NO);
if (!ereg((^(.*)[0-9]{3})(.*)([0-9]{3})(.*)([0-9]{4}$), $wphone_no))
{
   print_error(your bphone number/b is invalid);
}
 }

It would be helpful if you post a list of the range of phone numbers you are
encountering that you are having a problem with.  Or I can get you started
by saying that I think you're regular expression is saying beginning with
anything, then exactly 3 numbers, then anything, then exactly 3 numbers,
then anything, then ending in exactly 4 numbers.  Changing a {3} to {3,4}
would mean match 3-4 occurences of what's to the left.  Hopefully that
will get you started, if you post some other numbers you want to pass
validation we can be of more assistance.  regex are very powerful and I
recommend you add them to your training.  That said, people enter #s in many
different formats and sometimes it's necessary to enter a # like
011-817-972-1086 x103 or 817-972-1086, 1, 3, 12 if you're dealing with
business numbers with extensions or automated systems that have to be
traversed.  So you may be better off not validating the phone #.  YMMV.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/




RE: [PHP] validate phone numbers

2001-06-20 Thread scott [gts]

i agree.

there's NOTHING more annoying than a broken validation
script when you're trying to enter valid, but weird, data.

perhaps separate the form up into one box for the 
country code, one box for the number, and one box
for any add'l information (extensions, automated prompt
numbers, etc...), so that you'd only have to work at
validating the actual number (and not any extraneous
and oddly formatted info)


 -Original Message-
 From: Steve Werby [mailto:[EMAIL PROTECTED]]
 Subject: Re: [PHP] validate phone numbers
 
 people enter #s in many
 different formats and sometimes it's necessary to enter a # like
 011-817-972-1086 x103 or 817-972-1086, 1, 3, 12 if you're dealing with
 business numbers with extensions or automated systems that have to be
 traversed.  So you may be better off not validating the phone #.  YMMV.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] validate phone numbers

2001-06-20 Thread Miles Thompson

There are so many combinations of European phone numbers, along with the 
possible combinations of area codes, and hyphens or spaces may be used as 
well, I wouldn't bother. If the phone number is critical, and important to 
the person using your site, then treatitlike a password and have them enter 
it twice. Although in that  case they are likely to enter it correctly anyway.

One can only do so much.

Miles Thompson

At 07:24 PM 6/19/01 -0700, Richard Kurth wrote:
I am using this script to validate for phone numbers and it work just
perfect for US phone numbers. But it rejects some European and
Australian numbers what do I need to do to make it validate all phone
numbers

if (($WPHONE_NO) || ($wphone_no)) {
$wphone_no = trim($wphone_no);
if ($WPHONE_NO)
   $phone_no = trim($WPHONE_NO);
if (!ereg((^(.*)[0-9]{3})(.*)([0-9]{3})(.*)([0-9]{4}$), $wphone_no)) {
   print_error(your bphone number/b is invalid);
}
}











Best regards,
  Richard
mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]