I bound the event handler to specific buttons that changed the settings of the validator object in this particular form.
$(".jsCancel").click(function (e) { $(e.currentTarget).closest("form").validate().settings.ignore = "*" });
It worked like a charm for me in MVC3.
I donβt know if this helps you in particular, but since I use an ajax form, I had to attach an event to these buttons every time the contents of the ajax form were replaced using the ajax success for the event. Full code that rewrites the form and attaches the event to the cancel buttons:
$(document).ajaxSuccess(function (event, xhr, settings) { var $jQval = $.validator, adapters, data_validation = "unobtrusiveValidation"; $jQval.unobtrusive.parse(document); $(".jsCancel").click(function (e) { $(e.currentTarget).closest("form").validate().settings.ignore = "*" }); });
Skymt source share