I've a textbox which must contain only alfanumeric characters (a-z A-Z 0-9). Someone told me that I've to use a regular expression to check the text. I've tried with if (preg_match("[a-z A-Z 0-9]",$text) ) echo "ok"; but it doesn't work. Anyone could help me please?
Now I'm trying with ereg("[a-z A-Z 0-9]",$text)
and It seems to work until I insert a mixed text like aSd"£.
I've found a solution:
for ($i=0;$i<strlen($text);$i++) { if (!ereg("[a-z A-Z 0-9]",$text[$i])) die("Error in text!"); }