Basic mandatory field question

Hi,
My comments field - although mandatory - can be bypassed by just one mouse click/space bar click which creats just a blank space.

Would adding an extra blank space between the speech marks in the code - like this - work to stop the above being true? Would this then force a user to at least put in 2 letters/numbers or blank spaces?
[php]$comments==’ ') [/php]

[php]if (strspn($comments,“abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”) == 0) {
echo (‘fail’);
}else{
echo(‘success’);
}[/php]

Also if you want it to be a certain length
[php]if (strlen($comments) > 12) {[/php]

You can also use is_null() to check whether a variable is null. Example:
[php]
if(is_null($_POST[‘name’])){
echo “Field is empty”;
}
else{
echo “Success”;
}
[/php]

Will is_null return true when a space, " " is entered? or false?

Sponsor our Newsletter | Privacy Policy | Terms of Service