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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -