I have a website form that collects user details. The phone filed is awesome in that it validates the phone number and prevents anyone from leaving the field blank or typing in a word.
Here's how my regex looks for that field:
if (!preg_match('/^[0-9ext()+ -.:]{9,35}$/i', $Phone)){
$error.= "<li><font face=arial>Phone number is <em><strong>required</strong></em> if you're truly serious about generating $500/Day. Enter full number with area code. Also, you should use only the following characters: '+' , '0-9' , ' ( ' , ' ) ' , 'ext' , or 'x'. Example, <strong>(123) 555-1212</strong></font><br><br>";
$errors=1;
}
The problem I'm getting is that some are entering bogus numbers, like "555-1212" or "5551212". How can I add to the regex above to throw back the error message if someone adds the fake "5551212" number?
Inputs phone nos:(should be matched with 5551212
as a substring)
1-800-555-1212
8585551212
(619) 555-1212
Thanks for your awesome help!