> 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-xxxx.
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 {
print "bad\n";
}
The regexp breaks down like this:
[0-9]{3} [0-9]{3} [0-9]{4}
(three numbers)-(three numbers)-(four numbers)
I didn't test the code above, so let me know if it won't work for you.
Regards,
Sean
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]