I have a textarea. I am trying to check that it contains atleast 3 non-whitespace characters in javascript, and if it does, I need to recheck the posted message in php.
I think once I get it working in php, I can use the same regexp for javascript. However, the whitespaces are messing it up.
I don't understand why the following does not work in php:
$msg = mysql_real_escape_string($_POST["msg"]);
if(!preg_match('/[\S]{3,}/',$msg)){
echo 'too short';
}
To me it seems like that requires atleast 3 "non-whitespace character". However if I enter:
f f f
It says it is too short. And
f
d
passes. I've tried adding the "g" flag, and playing with ^ and $ surrounding the regexp.
Thanks for any tips