I'm setting up a custom php form validation used in conjunction with wordpress contact form 7 plugin, I've set up a validation rule as the text field, I only want people to type 1 word (i.e. no spaces) and for that one word to begin with the letter s.
The letter s validation works just fine but while this works, the no spaces (one word) validation doesn't seem to be working?
php:
if($name == 'FirstField') {
$FirstField = $_POST['FirstField'];
if($FirstField != '') {
if (!preg_match("/(^[^s]|\s)/i",$FirstField)){
$result['valid'] = true;
} else {
$result['valid'] = false;
$result['reason'][$name] = 'Invalid Entry.';
}
}
}
Any suggestions would be greatly appreciated!