Hello all,
So I'm trying to find a way to have the jQuery validation plugin simply return false when the form is invalid, and not show the error messages or do anything else. But this is proving more difficult than it should be. I'm setting up the validation as such:
var validator = $journalForm.validate({
rules: {
EntryDate: { required: true, date: true },
EvalStatus: { required: true },
EvalState: { required: true },
ActivityType: { required: true },
Duration: { required: true },
}
});
And I'm testing to see if the form is valid as such:
if ($form.valid()) {
alert("success");
}
else {
alert("fail");
}
The problem is that when it hits the if statement above, if the form is invalid, it doesn't even get to the else. Instead, it just shows the errors. However, if the form is valid, it reaches the alert and pops up "success". How can I just get a simple "false" returned from the plugin when the form doesn't pass the rules, and have it do nothing else?
Thanks.