php - Check for spaces using regex -
i'm using regex (i think that's it's called - haha) check users' name make sure it's valid. want make sure user doesn't have characters. letters , spaces. i've got letters part down, can't spaces part fixed.
here's i'm using now..
if(preg_match("/[^a-za-z]/", " ", $name) != 0) { $errorlist = $errorlist."<li>you must enter valid first , last name (check invalid characters)</li>"; }
anyone see i'm doing wrong?
just add space regex pattern. ps - second parameter preg_match() should $name, right? there reason testing " "?
if(preg_match("/[^a-za-z ]/", $name) != 0) { $errorlist = $errorlist."<li>you must enter valid first , last name (check invalid characters)</li>"; }
Comments
Post a Comment