> I am looking for code to verify a phone number has been entered correctly on
> a form field. Requirements would include the area code: xxx-xxx-.
You should use a regex for this. Something like...
if (ereg ("[0-9]{3}-[0-9]{3}-[0-9]{4}", $number)) {
print "good\n";
} else {
One way:
$phone = ereg_replace("[^0-9]", "", $phone);
if(!ereg("^[0-9]{10}$",$phoneHome")) {
echo "error";
}
You could also check the string length after removing all non-numbers.
Kirk
> -Original Message-
> From: Claudia Smith [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 11, 2001
2 matches
Mail list logo