Phone number validation

From: Date: Sun, 12 Mar 2006 19:09:42 +0000
Subject: Phone number validation
Groups: php.general 
Request: Send a blank email to php-general+get-231806@lists.php.net to get a copy of this message
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

« previous php.general (#231806) next »