hi, i need a pregmatch that validades a string from a field with numbers, letters, and spaces only. maybe i could use dashes, commas and accented letters later, but i dont know anything about regex, and its kinda hard to learn it with the available tutorials, so i'd be happy to have just my first need.
someone can help?
thanks!
validate input string with letters numbers and spaces
Moderator: General Moderators
-
rahulzatakia
- Forum Commoner
- Posts: 59
- Joined: Fri Feb 05, 2010 12:01 am
- Location: Ahmedabad
Re: validate input string with letters numbers and spaces
Hi, use the following code:
Code: Select all
$element = "xyz123 ";
preg_match("/^[a-zA-Z0-9 ]+$/",$element);
Re: validate input string with letters numbers and spaces
thanks mate, works like a charm!