If I've added a custom validation method to my form, how can I get it to trigger prior to submit?
I'm not decorating my form fields but I thought that adding the new method to my rules section would trigger the method but it doesn't work.
$.validator.addMethod('myCustomValidation', function (data)
{
// do some work here
return myValidationResult;
}, 'Please respond.');
$("#myFormId").validate({
rules: {
"myCustomValidation": {required: true}
},
messages: {
"myCustomValidation": {
required: "Enter some information before proceeding",
}
},
submitHandler: function(form)
{
// do the work to submit this form
}
});
I'd like have the validation get triggered when the 'submit' button is pressed.
However, if I add the validation class name to any form field except the submit button, this rule gets triggered. Just can't seem to get it to be triggered just prior to submit..