4

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....

staytouch
  • 41
  • 1
  • 3

3 Answers3

2

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

Community
  • 1
  • 1
Town
  • 14,706
  • 3
  • 48
  • 72
  • @staytouch: you can certain try! It looks that way from the answers in that question, although I haven't tested it myself. – Town Apr 15 '11 at 08:57
  • Ur Method doesnt works My updated codes using ur script is above. Please guide me to remove jquery.validate form validation by clicking cancel button – staytouch Apr 15 '11 at 09:09
  • @staytouch: see the edit in my answer. If you apply the `ignore` class to your `#close_button` element then it should ignore validation - is that what you're trying to do? – Town Apr 15 '11 at 14:40
1

use like:

  <input class="cancel" type="submit" value="Save" />
Anand Thangappan
  • 3,068
  • 2
  • 28
  • 31
0

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" />
Harshad Hirapara
  • 462
  • 3
  • 12