if(!preg_match("/[a-zA-Z'-]/",$First)) { die ("invalid first name");}
the above only flags input as invalid when the field is all numeric. combinations of letters and numbers pass ok. Some help here for a newby please. thanks.
Adding accented characters is probably smart too, so that "Pierre Bézier" can fill out your form. Adding:
À-ÿ
.. to your regex will do that. Something like this, with everything included:
/^([a-zA-ZÀ-ÿ-' ]+)$/
Try:
if(!preg_match("/^[a-zA-Z'-]+$/",$First)) { die ("invalid first name");}
The ^
matches the beginning of the string, the $
matches the end of the string and +
after a character group means "one or more" matching characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With