Reputation: 5941
I am using the jQuery Validator. And I'm trying to figure out: How can I un-attach the validator from my form once its submitted?
$(function() {
// Just the rules, etc...
validator = $("#sweepstakesForm").validate({rules: {fname: {required: true,minlength: 2,maxlength: 50},lname: {required: true,minlength: 2,maxlength: 50},email: {email: true,remote: "?c=home&m=jsHook¶m=email&nojson=1",required: true,minlength: 6,maxlength: 120},address: {required: true,minlength: 5,maxlength: 100},state_0: {required: true},state: ); // etc ...
$('#sweepstakesForm').submit() {
}
});
I have tried these to no avail:
validator = null;
$("#sweepstakesForm").unbind('validate');
delete validator;
Upvotes: 13
Views: 12510
Reputation: 33
Hello from 2020 :) My validator version is still 1.11.1 and none of the code snippets above worked properly (without errors in console). The one that did is:
$('form,input,select,textarea,button').attr("novalidate", "novalidate").attr("formnovalidate", "formnovalidate")
I know it affects many elements on the page, but for debugging its fine IMHO.
Upvotes: 0
Reputation: 10709
Try
$('#sweepstakesForm').data('validator', null);
$("#sweepstakesForm").unbind('validate');
Upvotes: 19
Reputation: 63529
I'm not really familiar with this plugin, but from the documentation it looks like what you want is:
$('#sweepstakesForm').rules('remove');
Upvotes: 1
Reputation: 25091
Try adding an .unbind('submit')
$('#sweepstakesForm').submit(function () {
$(this).unbind('submit');
});
Upvotes: 2