Quote OP:
"The preferred method would be through jQuery form validation."
To do this with the jQuery Validation plugin, you would write a custom rule using the .addMethod()
method. Return true
to pass and false
to fail validation (display message).
jQuery.validator.addMethod("noEmail", function(value, element) {
return (value.indexOf("@") == -1);
}, "Please don't enter an email address");
declared:
rules: {
myfield: {
noEmail: true
}
}
DEMO: http://jsfiddle.net/CW7Pt/
However, what makes you think the spam-bots are going to be using any jQuery/JavaScript? All anybody has to do is disable the JavaScript in their browser and there is no jQuery Validation. Since the spam-bots emulate browsers, they likely wouldn't bother to have anything enabled (like JavaScript) that would impede their task.
The far better solution is to use server-side (PHP & Zend) validation, which cannot be bypassed or disabled by any user.
framework.zend.com/manual/1.11/en/zend.validate.writing_validators.html
You would still use the jQuery Validation plugin to achieve a better user experience for your honest users.