Pattern matching Phone, Email
This is driving me nuts.
I am trying to validate a form, phone numbers, and the phone number has to be "xxx xxx-xxxx"
Here is my pattern
my code:
Also, if any one want to suggest a pattern for email, I'd take that too.
I am trying to validate a form, phone numbers, and the phone number has to be "xxx xxx-xxxx"
Here is my pattern
"^([0-9]{3})( [0-9]{3})([0-9]{4})$"my code:
function VALIDATE_USPHONE($phonenumber)
{
if ((preg_match("^([0-9]{3})( [0-9]{3})([0-9]{4})$", $phonenumber)) == TRUE ) {
return $phonenumber;
} else {
return false;
}
}
VALIDATE_USPHONE(trim($_POST[Home_Phone] ));
if ($phonenumber) {
$account['HOME_PHONE'] = trim($_POST[Home_Phone]);
}
Also, if any one want to suggest a pattern for email, I'd take that too.
