I use jQuery validation method and I've set some default settings such as below
$.validator.setDefaults({
errorContainer : "#msgErrors ul",
errorLabelContainer: "#msgErrors",
wrapper: "li",
submitHandler: function(form) {
lockScreen();
if (typeof url !== 'undefined' && url != null) {
loadContentViaAjax("tr#idElement", url, $(form).formSerialize(), "html");
} else {
form.submit();
}
},
invalidHandler: function() {
var divsMessages = $(".fadeOutAndEmpty");
if (divsMessages.is(":animated")) {
divsMessages.stop().removeAttr("style").show();
}
}
});
For these default settings work, I have to initialize the form by calling the validate method on every form that I have. To achieve this I placed after the page is fully loaded a call to
$("form").validate()
in an external JS file that is loaded by every page. This way all forms in my application will fire the validation method, but I didn't define any rules and calling validate method again passing the actual rules won't do the job.
Is there a way to define rules that has to be executed and those rules actually be executed even if the validate method has already been called?