New to regex - help validating a form field
Posted: Tue Jul 25, 2006 7:10 am
After reading posts and tutorials about regex I understand the basics and could use regex match function to identify a string.
I have a form which has a field in it. When someone submits the form, I want the script to make sure the field contains only letters (upper or lower case is fine), numbers, and spaces.
I was told regex is able to do this but I'm not sure how.
So far I've tried things along the lines of
I'm a little lost
I have a form which has a field in it. When someone submits the form, I want the script to make sure the field contains only letters (upper or lower case is fine), numbers, and spaces.
I was told regex is able to do this but I'm not sure how.
So far I've tried things along the lines of
Code: Select all
if (preg_match_all('/\w+ +/', $_POST['form_field'])) {return true;}