Phone Number Validation
Posted: Sat Dec 17, 2005 3:19 pm
Hey guys, was wondering if anyone had any particular code suggestions for validating phone numbers.. reg ex's, etc. Have been looking around without luck. Thanks and take care!
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
#http://www.owasp.org/software/validation.html
/*
phone
^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$
US phone number with or without dashes
*/
function isPhoneNumber($phn){
if (preg_match ("/^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$/", $phn))
return TRUE;
else
return FALSE;
}