preg_match_all form validation

Soldato
Joined
18 Apr 2004
Posts
2,613
Location
London
I am doing some basic form validation and I want to see if some thing contains characters other than letters, however the \P{l} element returns this error...

Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unknown property name after \P or \p at offset 3 in register_action.php on line 1.

Heres the code...

PHP:
1 preg_match_all("^[\P{l}]^", $_POST['firstname'], $output);
2 if (count($output) > 0) echo "bad times";

I thought it might be that you have to be in UTF8 mode but how?

Thanks!
 
PHP:
echo (preg_match("/^[a-zA-Z]+$/", $_POST['firstname']) <> 1 ? "bad times" : "")
Would return true and echo "bad times" if $_POST['firstname'] had anything but alphabetical characters in it, assume this is what you are wanting to do :)
 
Back
Top Bottom