Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove jQuery validation from a form?

I'm using the jQuery validation plugin to validate a form, and I'd like to remove the validation and submit the form if a certain link is clicked.

I am submitting form with javascript like jQuery('form#listing').submit(), so I must remove the validation rules/function with javascript.

The problem is that I can't figure out how to do this. I've tried things like jQuery('form#listing').validate({}); and jQuery('form#listing').validate = null, but with no luck.

like image 928
Ben Crouse Avatar asked Dec 12 '08 16:12

Ben Crouse


People also ask

How remove validation after field is valid using jQuery?

You want the resetForm() method: var validator = $("#myform"). validate( ... ... ); $(". cancel").

How remove validation message after field is valid?

Adding an else statement to return the value of your error message span to a non-error state could correct this. this should display your error msg and return it to blank when a valid input is present.


2 Answers

Trigger the DOM submit method to skip the validation:

$("#listing")[0].submit(); 
like image 145
Jörn Zaefferer Avatar answered Sep 28 '22 02:09

Jörn Zaefferer


You can remove events of nodes with unbind:

jQuery('form#listing').unbind('submit'); // remove all submit handlers of the form 

What you are probably looking for is that the validation plugin can also unassign itself from the submit event:

jQuery('form#listing').validate({    onsubmit : false }); 

For both of these you should be able to follow up with a call to .submit() to submit the form:

jQuery('form#listing').unbind('submit').submit(); 
like image 34
Borgar Avatar answered Sep 28 '22 01:09

Borgar