Phone number validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I am trying to validate phone numbers in a web form that I have
created.  I am using a regular expression to validate the phone
number.  It seems when I enter the phone number in the following ways
I get errors

(123) 456 7890
123 456 7890
(123) 456 - 7890
123 456-7890

I am using the ereg method in php to test the regular expression. 
Here is the Regular Expression that I am using to test against
potential phone numbers

$validPhone = "^([0-9]{3}[ ]*)?[0-9]{3}[ ]*[0-9]{4}$";

By the way The phone numbers are in US format.

If anyone can help me with this I would really appreciate it.

Thanks,
Paul

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux