staytouch
staytouch

Reputation: 41

How to remove jquery.validate from my form

I am using jquery.validate plugin to check my form which comes in popup.

So How to remove validation for that form. i had tried this

$("#close_button").click(function(){
    var settings = $('form#user_form').validate().settings;
         // Modify validation settings
    $.extend(settings, {
        rules: {}
    });
    tb_remove();
});

I need to remove validation of my form. Help me. Thanks in advance...

Updated Code...

$("#close_button").click(function(){
     $("form#user_form").validate().cancelSubmit = true;
});

I had also tried

<input type="button" class="cancel" name="close_button" id="close_button" value="Cancel">

I had just added class cancel to remove validation of concern form.

My method doesnt works. Help to solve this....

Upvotes: 4

Views: 7596

Answers (3)

Harshad Hirapara
Harshad Hirapara

Reputation: 462

You can add a css class of cancel to a submit button to suppress the validation

e.g

<input class="cancel" type="submit" value="Save" />

See the jQuery Validator documentation of this feature here: Skipping validation on submit

EDIT:

The above technique has been deprecated and replaced with the formnovalidate attribute.

<input formnovalidate="formnovalidate" type="submit" value="Save" />

Upvotes: 0

Town
Town

Reputation: 14906

There are several solutions in this question: jQuery Validation plugin: disable validation for specified submit buttons

$("form").validate().cancelSubmit = true;

Looks like what you're after.

EDIT: You can configure the CSS class to disable validation when you attach validate() to your form, like this:

$("#myform").validate({
   ignore: ".ignore"
})

The example is from this question: jQuery Validation plugin: disable validation for specified submit buttons when there is submitHandler handler

Upvotes: 2

Anand Thangappan
Anand Thangappan

Reputation: 3106

use like:

  <input class="cancel" type="submit" value="Save" />

Upvotes: 1

Related Questions