Possible Duplicate:
A comprehensive regex for phone number validation
please i created this function for mail and phone number validation, the mail own works, bt the phone own does nt work.
if(trim($_POST['email']) == '') {
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$",
trim($_POST['email']))) {
$hasError = true;
} else {
$email = trim($_POST['email']);
}
if(trim($_POST['phonenumber']) == '') {
$hasError = true;
} else if (!eregi("/^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/$",
trim($_POST['phonenumber']))) {
$hasError = true;
} else {
$phonenumber= trim($_POST['phonenumber']);
}