jQuery Validate - Enable validation for hidden fields









up vote
164
down vote

favorite
44












In the new version of jQuery validation plugin 1.9 by default validation of hidden fields ignored. I'm using CKEditor for textarea input field and it hides the field and replace it with iframe. The field is there, but validation disabled for hidden fields. With validation plugin version 1.8.1 everything works as expected.



So my question is how to enable validation for hidden fields with v1.9 validation plugin.



This setting doesn't work:



$.validator.setDefaults( ignore: '' );









share|improve this question

















  • 1




    See also stackoverflow.com/questions/7952181/…
    – goodeye
    Jul 5 '14 at 19:33










  • The link for "validation of hidden fields ignored" is dead.
    – Beepye
    Sep 20 '16 at 15:00










  • Validation is working by default for me with <input type="text" name="myfield" id="myfield" required="required" style="display: none;">. I didn't have to change any settings or do anything special.
    – squarecandy
    Sep 2 at 18:24














up vote
164
down vote

favorite
44












In the new version of jQuery validation plugin 1.9 by default validation of hidden fields ignored. I'm using CKEditor for textarea input field and it hides the field and replace it with iframe. The field is there, but validation disabled for hidden fields. With validation plugin version 1.8.1 everything works as expected.



So my question is how to enable validation for hidden fields with v1.9 validation plugin.



This setting doesn't work:



$.validator.setDefaults( ignore: '' );









share|improve this question

















  • 1




    See also stackoverflow.com/questions/7952181/…
    – goodeye
    Jul 5 '14 at 19:33










  • The link for "validation of hidden fields ignored" is dead.
    – Beepye
    Sep 20 '16 at 15:00










  • Validation is working by default for me with <input type="text" name="myfield" id="myfield" required="required" style="display: none;">. I didn't have to change any settings or do anything special.
    – squarecandy
    Sep 2 at 18:24












up vote
164
down vote

favorite
44









up vote
164
down vote

favorite
44






44





In the new version of jQuery validation plugin 1.9 by default validation of hidden fields ignored. I'm using CKEditor for textarea input field and it hides the field and replace it with iframe. The field is there, but validation disabled for hidden fields. With validation plugin version 1.8.1 everything works as expected.



So my question is how to enable validation for hidden fields with v1.9 validation plugin.



This setting doesn't work:



$.validator.setDefaults( ignore: '' );









share|improve this question













In the new version of jQuery validation plugin 1.9 by default validation of hidden fields ignored. I'm using CKEditor for textarea input field and it hides the field and replace it with iframe. The field is there, but validation disabled for hidden fields. With validation plugin version 1.8.1 everything works as expected.



So my question is how to enable validation for hidden fields with v1.9 validation plugin.



This setting doesn't work:



$.validator.setDefaults( ignore: '' );






jquery-validate






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 11 '11 at 19:08









Shaman

1,80821613




1,80821613







  • 1




    See also stackoverflow.com/questions/7952181/…
    – goodeye
    Jul 5 '14 at 19:33










  • The link for "validation of hidden fields ignored" is dead.
    – Beepye
    Sep 20 '16 at 15:00










  • Validation is working by default for me with <input type="text" name="myfield" id="myfield" required="required" style="display: none;">. I didn't have to change any settings or do anything special.
    – squarecandy
    Sep 2 at 18:24












  • 1




    See also stackoverflow.com/questions/7952181/…
    – goodeye
    Jul 5 '14 at 19:33










  • The link for "validation of hidden fields ignored" is dead.
    – Beepye
    Sep 20 '16 at 15:00










  • Validation is working by default for me with <input type="text" name="myfield" id="myfield" required="required" style="display: none;">. I didn't have to change any settings or do anything special.
    – squarecandy
    Sep 2 at 18:24







1




1




See also stackoverflow.com/questions/7952181/…
– goodeye
Jul 5 '14 at 19:33




See also stackoverflow.com/questions/7952181/…
– goodeye
Jul 5 '14 at 19:33












The link for "validation of hidden fields ignored" is dead.
– Beepye
Sep 20 '16 at 15:00




The link for "validation of hidden fields ignored" is dead.
– Beepye
Sep 20 '16 at 15:00












Validation is working by default for me with <input type="text" name="myfield" id="myfield" required="required" style="display: none;">. I didn't have to change any settings or do anything special.
– squarecandy
Sep 2 at 18:24




Validation is working by default for me with <input type="text" name="myfield" id="myfield" required="required" style="display: none;">. I didn't have to change any settings or do anything special.
– squarecandy
Sep 2 at 18:24












8 Answers
8






active

oldest

votes

















up vote
291
down vote



accepted










The plugin's author says you should use "square brackets without the quotes",



http://bassistance.de/2011/10/07/release-validation-plugin-1-9-0/




Release: Validation Plugin 1.9.0:
"...Another change should make the setup of forms with hidden elements
easier, these are now ignored by default (option “ignore” has
“:hidden” now as default). In theory, this could break an existing
setup. In the unlikely case that it actually does, you can fix it by
setting the ignore-option to “” (square brackets without the
quotes)."




To change this setting for all forms:



$.validator.setDefaults( 
ignore: ,
// any other default options and/or rules
);


(It is not required that .setDefaults() be within the document.ready function)



OR for one specific form:



$(document).ready(function() 

$('#myform').validate(
ignore: ,
// any other options and/or rules
);

);



EDIT:



See this answer for how to enable validation on some hidden fields but still ignore others.




EDIT 2:



Before leaving comments that "this does not work", keep in mind that the OP is simply asking about the jQuery Validate plugin and his question has nothing to do with how ASP.NET, MVC, or any other Microsoft framework can alter this plugin's normal expected behavior. If you're using a Microsoft framework, the default functioning of the jQuery Validate plugin is over-written by Microsoft's unobtrusive-validation plugin.



If you're struggling with the unobtrusive-validation plugin, then please refer to this answer instead: https://stackoverflow.com/a/11053251/594235






share|improve this answer


















  • 25




    Maybe the down-voter can give me some constructive feedback. Otherwise, the answer is fully self-contained, properly sourced, gives code examples, and is technically correct as per the plugin's author.
    – Sparky
    Mar 17 '13 at 0:41







  • 1




    @StijnVanBael, no, that is false. See: jsfiddle.net/F4w92/1 and also see my second comment on jerick's answer.
    – Sparky
    Jul 11 '13 at 14:57







  • 4




    Well said @Sparky. The down-votes are probably kind of revenge, I've encountered the same..
    – Omar
    Jul 22 '13 at 11:02






  • 1




    The JSFiddle doesn't work anymore because the libraries are loaded in HTTP instead of HTTPS. Updated version : jsfiddle.net/F4w92/31
    – hotips
    Jun 5 '15 at 14:55






  • 1




    I downvoted also as this does not work for me using latest version, had to use: $("form").data("validator").settings.ignore = ""; as other answer from @James bellow
    – Mark Homer
    Oct 9 '15 at 14:07

















up vote
66
down vote













This worked for me, within an ASP.NET MVC3 site where I'd left the framework to setup unobtrusive validation etc., in case it's useful to anyone:



$("form").data("validator").settings.ignore = "";





share|improve this answer
















  • 1




    This one worked for me. Thanks.
    – peterorum
    Aug 28 '12 at 6:08






  • 2




    I also like this one since it means I can do it in certain circumstances, rather than changing the default behaviour.
    – Steve Owen
    Oct 29 '12 at 15:40






  • 5




    I had to do it this way, because using .validate() to change the options wasn't working.
    – Farinha
    Apr 4 '14 at 13:01










  • Champion! Thanks for this, worked in MVC5
    – m.t.bennett
    Nov 10 '15 at 6:04










  • this is the correct solution for the unobtrusive validation, I tried all the other solutions, they could work in case NOT using unobtrusive. If you are using unobtrusive here is right place.
    – Hakam Fostok
    Nov 30 '16 at 8:32

















up vote
63
down vote













Make sure to put



 $.validator.setDefaults( ignore: '' );


NOT inside $(document).ready






share|improve this answer


















  • 2




    Excellent answer. A link to the documentation is good for people to learn, but a straight up answer is more valuable imo. He OP was on the right track, but putting it outside of $(document).ready is the trick.
    – Kevin Zych
    Feb 2 '13 at 1:39







  • 3




    @KevinZych, Apparently, it makes absolutely no difference whether $.validator.setDefaults() is placed inside or outside of the DOM ready hander. Compare this jsFiddle to this jsFiddle.
    – Sparky
    Apr 9 '13 at 20:40











  • Interesting @Sparky, your fiddles are excellent proof. I'd have to go back and look at the code I fixed using this solution and find out why I came to the conclusion that it had to be inside of the DOM ready handler. Must have been some other reason.
    – Kevin Zych
    Apr 10 '13 at 3:26










  • The same as you guys, in my code that doesn't work inside DOM ready...
    – molokoloco
    Apr 18 '13 at 11:48










  • Justin explains why running inside doc ready causes problems. However, this answer is not a good option because it's hard to guarantee that something outside doc ready will run BEFORE doc ready. Doc.ready will not wait for scripts outside of it to run. Nothing personal, but this isn't a reliable answer.
    – AaronLS
    Sep 9 '13 at 18:55


















up vote
26
down vote













So I'm going to go a bit deeper in to why this doesn't work because I'm the kind of person that can't sleep at night without knowing haha. I'm using jQuery validate 1.10 and Microsoft jQuery Unobtrusive Validation 2.0.20710.0 which was published on 1/29/2013.



I started by searching for the setDefaults method in jQuery Validate and found it on line 261 of the unminified file. All this function really does is merge your json settings in to the existing $.validator.defaults which are initialized with the ignore property being set to ":hidden" along with the other defaults defined in jQuery Validate. So at this point we've overridden ignore. Now let's see where this defaults property is being referenced at.



When I traced through the code to see where $.validator.defaults is being referenced. I noticed that is was only being used by the constructor for a form validator, line 170 in jQuery validate unminified file.



// constructor for validator
$.validator = function( options, form )
this.settings = $.extend( true, , $.validator.defaults, options );
this.currentForm = form;
this.init();
;


At this point a validator will merge any default settings that were set and attach it to the form validator. When you look at the code that is doing the validating, highlighting, unhighlighting, etc they all use the validator.settings object to pull the ignore property. So we need to make sure if we are to set the ignore with the setDefaults method then it has to occur before the $("form").validate() is called.



If you're using Asp.net MVC and the unobtrusive plugin, then you'll realize after looking at the javascript that validate is called in document.ready. I've also called my setDefaults in the document.ready block which is going to execute after the scripts, jquery validate and unobtrusive because I've defined those scripts in the html before the one that has the call in it. So my call obviously had no impact on the default functionality of skipping hidden elements during validation. There is a couple of options here.



Option 1 - You could as Juan Mellado pointed out have the call outside of the document.ready which would execute as soon as the script has been loaded. I'm not sure about the timing of this since browsers are now capable of doing parallel script loading. If I'm just being over cautious then please correct me. Also, there's probably ways around this but for my needs I did not go down this path.



Option 2a - The safe bet in my eyes is to just replace the $.validator.setDefaults( ignore: '' ); inside of the document.ready event with $("form").data("validator").settings.ignore = "";. This will modify the ignore property that is actually used by jQuery validate when doing each validation on your elements for the given form.



Options 2b - After looking in to the code a bit more you could also use $("form").validate().settings.ignore = ""; as a way of setting the ignore property. The reason is that when looking at the validate function it checks to see if a validator object has already been stored for the form element via the $.data() function. If it finds a validator object stored with the form element then it just returns the validator object instead of creating another one.






share|improve this answer






















  • option 2 works.
    – SSA
    Jan 31 '13 at 13:17










  • Thank you for the detailed answer!
    – davidallyoung
    Feb 20 '15 at 17:47










  • Good work as the OP answer didn't work for me in MVC 5
    – Mark Homer
    Oct 9 '15 at 14:36










  • your analysis helped me a lot in fixing one my validation issues. +1
    – Prasoon
    May 3 '16 at 6:11

















up vote
8
down vote













Just added ignore: in the specific page for the specific form, this solution worked for me.



$("#form_name").validate(
ignore: ,
onkeyup: false,
rules:
,
highlight:false,
);





share|improve this answer





























    up vote
    6
    down vote













    This worked for me within an ASP.NET site.
    To enable validation on some hidden fields use this code



    $("form").data("validator").settings.ignore = ":hidden:not(#myitem)";



    To enable validation for all elements of form use this one
    $("form").data("validator").settings.ignore = "";



    Note that use them within $(document).ready(function() )






    share|improve this answer



























      up vote
      0
      down vote













      This is working for me.



      jQuery("#form_name").validate().settings.ignore = "";





      share|improve this answer



























        up vote
        -12
        down vote













        Just find the text ignore: ":hidden" in your jquery validation file and comment it.
        After comment this it will never loss any hidden elements to validate...



        Thanks






        share|improve this answer
















        • 5




          Never a good idea to just randomly comment out code in a third party library.
          – Jacques
          Oct 12 '15 at 13:45









        protected by Sparky May 31 '14 at 22:40



        Thank you for your interest in this question.
        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



        Would you like to answer one of these unanswered questions instead?














        8 Answers
        8






        active

        oldest

        votes








        8 Answers
        8






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        291
        down vote



        accepted










        The plugin's author says you should use "square brackets without the quotes",



        http://bassistance.de/2011/10/07/release-validation-plugin-1-9-0/




        Release: Validation Plugin 1.9.0:
        "...Another change should make the setup of forms with hidden elements
        easier, these are now ignored by default (option “ignore” has
        “:hidden” now as default). In theory, this could break an existing
        setup. In the unlikely case that it actually does, you can fix it by
        setting the ignore-option to “” (square brackets without the
        quotes)."




        To change this setting for all forms:



        $.validator.setDefaults( 
        ignore: ,
        // any other default options and/or rules
        );


        (It is not required that .setDefaults() be within the document.ready function)



        OR for one specific form:



        $(document).ready(function() 

        $('#myform').validate(
        ignore: ,
        // any other options and/or rules
        );

        );



        EDIT:



        See this answer for how to enable validation on some hidden fields but still ignore others.




        EDIT 2:



        Before leaving comments that "this does not work", keep in mind that the OP is simply asking about the jQuery Validate plugin and his question has nothing to do with how ASP.NET, MVC, or any other Microsoft framework can alter this plugin's normal expected behavior. If you're using a Microsoft framework, the default functioning of the jQuery Validate plugin is over-written by Microsoft's unobtrusive-validation plugin.



        If you're struggling with the unobtrusive-validation plugin, then please refer to this answer instead: https://stackoverflow.com/a/11053251/594235






        share|improve this answer


















        • 25




          Maybe the down-voter can give me some constructive feedback. Otherwise, the answer is fully self-contained, properly sourced, gives code examples, and is technically correct as per the plugin's author.
          – Sparky
          Mar 17 '13 at 0:41







        • 1




          @StijnVanBael, no, that is false. See: jsfiddle.net/F4w92/1 and also see my second comment on jerick's answer.
          – Sparky
          Jul 11 '13 at 14:57







        • 4




          Well said @Sparky. The down-votes are probably kind of revenge, I've encountered the same..
          – Omar
          Jul 22 '13 at 11:02






        • 1




          The JSFiddle doesn't work anymore because the libraries are loaded in HTTP instead of HTTPS. Updated version : jsfiddle.net/F4w92/31
          – hotips
          Jun 5 '15 at 14:55






        • 1




          I downvoted also as this does not work for me using latest version, had to use: $("form").data("validator").settings.ignore = ""; as other answer from @James bellow
          – Mark Homer
          Oct 9 '15 at 14:07














        up vote
        291
        down vote



        accepted










        The plugin's author says you should use "square brackets without the quotes",



        http://bassistance.de/2011/10/07/release-validation-plugin-1-9-0/




        Release: Validation Plugin 1.9.0:
        "...Another change should make the setup of forms with hidden elements
        easier, these are now ignored by default (option “ignore” has
        “:hidden” now as default). In theory, this could break an existing
        setup. In the unlikely case that it actually does, you can fix it by
        setting the ignore-option to “” (square brackets without the
        quotes)."




        To change this setting for all forms:



        $.validator.setDefaults( 
        ignore: ,
        // any other default options and/or rules
        );


        (It is not required that .setDefaults() be within the document.ready function)



        OR for one specific form:



        $(document).ready(function() 

        $('#myform').validate(
        ignore: ,
        // any other options and/or rules
        );

        );



        EDIT:



        See this answer for how to enable validation on some hidden fields but still ignore others.




        EDIT 2:



        Before leaving comments that "this does not work", keep in mind that the OP is simply asking about the jQuery Validate plugin and his question has nothing to do with how ASP.NET, MVC, or any other Microsoft framework can alter this plugin's normal expected behavior. If you're using a Microsoft framework, the default functioning of the jQuery Validate plugin is over-written by Microsoft's unobtrusive-validation plugin.



        If you're struggling with the unobtrusive-validation plugin, then please refer to this answer instead: https://stackoverflow.com/a/11053251/594235






        share|improve this answer


















        • 25




          Maybe the down-voter can give me some constructive feedback. Otherwise, the answer is fully self-contained, properly sourced, gives code examples, and is technically correct as per the plugin's author.
          – Sparky
          Mar 17 '13 at 0:41







        • 1




          @StijnVanBael, no, that is false. See: jsfiddle.net/F4w92/1 and also see my second comment on jerick's answer.
          – Sparky
          Jul 11 '13 at 14:57







        • 4




          Well said @Sparky. The down-votes are probably kind of revenge, I've encountered the same..
          – Omar
          Jul 22 '13 at 11:02






        • 1




          The JSFiddle doesn't work anymore because the libraries are loaded in HTTP instead of HTTPS. Updated version : jsfiddle.net/F4w92/31
          – hotips
          Jun 5 '15 at 14:55






        • 1




          I downvoted also as this does not work for me using latest version, had to use: $("form").data("validator").settings.ignore = ""; as other answer from @James bellow
          – Mark Homer
          Oct 9 '15 at 14:07












        up vote
        291
        down vote



        accepted







        up vote
        291
        down vote



        accepted






        The plugin's author says you should use "square brackets without the quotes",



        http://bassistance.de/2011/10/07/release-validation-plugin-1-9-0/




        Release: Validation Plugin 1.9.0:
        "...Another change should make the setup of forms with hidden elements
        easier, these are now ignored by default (option “ignore” has
        “:hidden” now as default). In theory, this could break an existing
        setup. In the unlikely case that it actually does, you can fix it by
        setting the ignore-option to “” (square brackets without the
        quotes)."




        To change this setting for all forms:



        $.validator.setDefaults( 
        ignore: ,
        // any other default options and/or rules
        );


        (It is not required that .setDefaults() be within the document.ready function)



        OR for one specific form:



        $(document).ready(function() 

        $('#myform').validate(
        ignore: ,
        // any other options and/or rules
        );

        );



        EDIT:



        See this answer for how to enable validation on some hidden fields but still ignore others.




        EDIT 2:



        Before leaving comments that "this does not work", keep in mind that the OP is simply asking about the jQuery Validate plugin and his question has nothing to do with how ASP.NET, MVC, or any other Microsoft framework can alter this plugin's normal expected behavior. If you're using a Microsoft framework, the default functioning of the jQuery Validate plugin is over-written by Microsoft's unobtrusive-validation plugin.



        If you're struggling with the unobtrusive-validation plugin, then please refer to this answer instead: https://stackoverflow.com/a/11053251/594235






        share|improve this answer














        The plugin's author says you should use "square brackets without the quotes",



        http://bassistance.de/2011/10/07/release-validation-plugin-1-9-0/




        Release: Validation Plugin 1.9.0:
        "...Another change should make the setup of forms with hidden elements
        easier, these are now ignored by default (option “ignore” has
        “:hidden” now as default). In theory, this could break an existing
        setup. In the unlikely case that it actually does, you can fix it by
        setting the ignore-option to “” (square brackets without the
        quotes)."




        To change this setting for all forms:



        $.validator.setDefaults( 
        ignore: ,
        // any other default options and/or rules
        );


        (It is not required that .setDefaults() be within the document.ready function)



        OR for one specific form:



        $(document).ready(function() 

        $('#myform').validate(
        ignore: ,
        // any other options and/or rules
        );

        );



        EDIT:



        See this answer for how to enable validation on some hidden fields but still ignore others.




        EDIT 2:



        Before leaving comments that "this does not work", keep in mind that the OP is simply asking about the jQuery Validate plugin and his question has nothing to do with how ASP.NET, MVC, or any other Microsoft framework can alter this plugin's normal expected behavior. If you're using a Microsoft framework, the default functioning of the jQuery Validate plugin is over-written by Microsoft's unobtrusive-validation plugin.



        If you're struggling with the unobtrusive-validation plugin, then please refer to this answer instead: https://stackoverflow.com/a/11053251/594235







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 23 '17 at 12:02









        Community

        11




        11










        answered Dec 19 '11 at 18:34









        Sparky

        81.3k20146235




        81.3k20146235







        • 25




          Maybe the down-voter can give me some constructive feedback. Otherwise, the answer is fully self-contained, properly sourced, gives code examples, and is technically correct as per the plugin's author.
          – Sparky
          Mar 17 '13 at 0:41







        • 1




          @StijnVanBael, no, that is false. See: jsfiddle.net/F4w92/1 and also see my second comment on jerick's answer.
          – Sparky
          Jul 11 '13 at 14:57







        • 4




          Well said @Sparky. The down-votes are probably kind of revenge, I've encountered the same..
          – Omar
          Jul 22 '13 at 11:02






        • 1




          The JSFiddle doesn't work anymore because the libraries are loaded in HTTP instead of HTTPS. Updated version : jsfiddle.net/F4w92/31
          – hotips
          Jun 5 '15 at 14:55






        • 1




          I downvoted also as this does not work for me using latest version, had to use: $("form").data("validator").settings.ignore = ""; as other answer from @James bellow
          – Mark Homer
          Oct 9 '15 at 14:07












        • 25




          Maybe the down-voter can give me some constructive feedback. Otherwise, the answer is fully self-contained, properly sourced, gives code examples, and is technically correct as per the plugin's author.
          – Sparky
          Mar 17 '13 at 0:41







        • 1




          @StijnVanBael, no, that is false. See: jsfiddle.net/F4w92/1 and also see my second comment on jerick's answer.
          – Sparky
          Jul 11 '13 at 14:57







        • 4




          Well said @Sparky. The down-votes are probably kind of revenge, I've encountered the same..
          – Omar
          Jul 22 '13 at 11:02






        • 1




          The JSFiddle doesn't work anymore because the libraries are loaded in HTTP instead of HTTPS. Updated version : jsfiddle.net/F4w92/31
          – hotips
          Jun 5 '15 at 14:55






        • 1




          I downvoted also as this does not work for me using latest version, had to use: $("form").data("validator").settings.ignore = ""; as other answer from @James bellow
          – Mark Homer
          Oct 9 '15 at 14:07







        25




        25




        Maybe the down-voter can give me some constructive feedback. Otherwise, the answer is fully self-contained, properly sourced, gives code examples, and is technically correct as per the plugin's author.
        – Sparky
        Mar 17 '13 at 0:41





        Maybe the down-voter can give me some constructive feedback. Otherwise, the answer is fully self-contained, properly sourced, gives code examples, and is technically correct as per the plugin's author.
        – Sparky
        Mar 17 '13 at 0:41





        1




        1




        @StijnVanBael, no, that is false. See: jsfiddle.net/F4w92/1 and also see my second comment on jerick's answer.
        – Sparky
        Jul 11 '13 at 14:57





        @StijnVanBael, no, that is false. See: jsfiddle.net/F4w92/1 and also see my second comment on jerick's answer.
        – Sparky
        Jul 11 '13 at 14:57





        4




        4




        Well said @Sparky. The down-votes are probably kind of revenge, I've encountered the same..
        – Omar
        Jul 22 '13 at 11:02




        Well said @Sparky. The down-votes are probably kind of revenge, I've encountered the same..
        – Omar
        Jul 22 '13 at 11:02




        1




        1




        The JSFiddle doesn't work anymore because the libraries are loaded in HTTP instead of HTTPS. Updated version : jsfiddle.net/F4w92/31
        – hotips
        Jun 5 '15 at 14:55




        The JSFiddle doesn't work anymore because the libraries are loaded in HTTP instead of HTTPS. Updated version : jsfiddle.net/F4w92/31
        – hotips
        Jun 5 '15 at 14:55




        1




        1




        I downvoted also as this does not work for me using latest version, had to use: $("form").data("validator").settings.ignore = ""; as other answer from @James bellow
        – Mark Homer
        Oct 9 '15 at 14:07




        I downvoted also as this does not work for me using latest version, had to use: $("form").data("validator").settings.ignore = ""; as other answer from @James bellow
        – Mark Homer
        Oct 9 '15 at 14:07












        up vote
        66
        down vote













        This worked for me, within an ASP.NET MVC3 site where I'd left the framework to setup unobtrusive validation etc., in case it's useful to anyone:



        $("form").data("validator").settings.ignore = "";





        share|improve this answer
















        • 1




          This one worked for me. Thanks.
          – peterorum
          Aug 28 '12 at 6:08






        • 2




          I also like this one since it means I can do it in certain circumstances, rather than changing the default behaviour.
          – Steve Owen
          Oct 29 '12 at 15:40






        • 5




          I had to do it this way, because using .validate() to change the options wasn't working.
          – Farinha
          Apr 4 '14 at 13:01










        • Champion! Thanks for this, worked in MVC5
          – m.t.bennett
          Nov 10 '15 at 6:04










        • this is the correct solution for the unobtrusive validation, I tried all the other solutions, they could work in case NOT using unobtrusive. If you are using unobtrusive here is right place.
          – Hakam Fostok
          Nov 30 '16 at 8:32














        up vote
        66
        down vote













        This worked for me, within an ASP.NET MVC3 site where I'd left the framework to setup unobtrusive validation etc., in case it's useful to anyone:



        $("form").data("validator").settings.ignore = "";





        share|improve this answer
















        • 1




          This one worked for me. Thanks.
          – peterorum
          Aug 28 '12 at 6:08






        • 2




          I also like this one since it means I can do it in certain circumstances, rather than changing the default behaviour.
          – Steve Owen
          Oct 29 '12 at 15:40






        • 5




          I had to do it this way, because using .validate() to change the options wasn't working.
          – Farinha
          Apr 4 '14 at 13:01










        • Champion! Thanks for this, worked in MVC5
          – m.t.bennett
          Nov 10 '15 at 6:04










        • this is the correct solution for the unobtrusive validation, I tried all the other solutions, they could work in case NOT using unobtrusive. If you are using unobtrusive here is right place.
          – Hakam Fostok
          Nov 30 '16 at 8:32












        up vote
        66
        down vote










        up vote
        66
        down vote









        This worked for me, within an ASP.NET MVC3 site where I'd left the framework to setup unobtrusive validation etc., in case it's useful to anyone:



        $("form").data("validator").settings.ignore = "";





        share|improve this answer












        This worked for me, within an ASP.NET MVC3 site where I'd left the framework to setup unobtrusive validation etc., in case it's useful to anyone:



        $("form").data("validator").settings.ignore = "";






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 15 '12 at 15:01









        James Morcom

        1,2941117




        1,2941117







        • 1




          This one worked for me. Thanks.
          – peterorum
          Aug 28 '12 at 6:08






        • 2




          I also like this one since it means I can do it in certain circumstances, rather than changing the default behaviour.
          – Steve Owen
          Oct 29 '12 at 15:40






        • 5




          I had to do it this way, because using .validate() to change the options wasn't working.
          – Farinha
          Apr 4 '14 at 13:01










        • Champion! Thanks for this, worked in MVC5
          – m.t.bennett
          Nov 10 '15 at 6:04










        • this is the correct solution for the unobtrusive validation, I tried all the other solutions, they could work in case NOT using unobtrusive. If you are using unobtrusive here is right place.
          – Hakam Fostok
          Nov 30 '16 at 8:32












        • 1




          This one worked for me. Thanks.
          – peterorum
          Aug 28 '12 at 6:08






        • 2




          I also like this one since it means I can do it in certain circumstances, rather than changing the default behaviour.
          – Steve Owen
          Oct 29 '12 at 15:40






        • 5




          I had to do it this way, because using .validate() to change the options wasn't working.
          – Farinha
          Apr 4 '14 at 13:01










        • Champion! Thanks for this, worked in MVC5
          – m.t.bennett
          Nov 10 '15 at 6:04










        • this is the correct solution for the unobtrusive validation, I tried all the other solutions, they could work in case NOT using unobtrusive. If you are using unobtrusive here is right place.
          – Hakam Fostok
          Nov 30 '16 at 8:32







        1




        1




        This one worked for me. Thanks.
        – peterorum
        Aug 28 '12 at 6:08




        This one worked for me. Thanks.
        – peterorum
        Aug 28 '12 at 6:08




        2




        2




        I also like this one since it means I can do it in certain circumstances, rather than changing the default behaviour.
        – Steve Owen
        Oct 29 '12 at 15:40




        I also like this one since it means I can do it in certain circumstances, rather than changing the default behaviour.
        – Steve Owen
        Oct 29 '12 at 15:40




        5




        5




        I had to do it this way, because using .validate() to change the options wasn't working.
        – Farinha
        Apr 4 '14 at 13:01




        I had to do it this way, because using .validate() to change the options wasn't working.
        – Farinha
        Apr 4 '14 at 13:01












        Champion! Thanks for this, worked in MVC5
        – m.t.bennett
        Nov 10 '15 at 6:04




        Champion! Thanks for this, worked in MVC5
        – m.t.bennett
        Nov 10 '15 at 6:04












        this is the correct solution for the unobtrusive validation, I tried all the other solutions, they could work in case NOT using unobtrusive. If you are using unobtrusive here is right place.
        – Hakam Fostok
        Nov 30 '16 at 8:32




        this is the correct solution for the unobtrusive validation, I tried all the other solutions, they could work in case NOT using unobtrusive. If you are using unobtrusive here is right place.
        – Hakam Fostok
        Nov 30 '16 at 8:32










        up vote
        63
        down vote













        Make sure to put



         $.validator.setDefaults( ignore: '' );


        NOT inside $(document).ready






        share|improve this answer


















        • 2




          Excellent answer. A link to the documentation is good for people to learn, but a straight up answer is more valuable imo. He OP was on the right track, but putting it outside of $(document).ready is the trick.
          – Kevin Zych
          Feb 2 '13 at 1:39







        • 3




          @KevinZych, Apparently, it makes absolutely no difference whether $.validator.setDefaults() is placed inside or outside of the DOM ready hander. Compare this jsFiddle to this jsFiddle.
          – Sparky
          Apr 9 '13 at 20:40











        • Interesting @Sparky, your fiddles are excellent proof. I'd have to go back and look at the code I fixed using this solution and find out why I came to the conclusion that it had to be inside of the DOM ready handler. Must have been some other reason.
          – Kevin Zych
          Apr 10 '13 at 3:26










        • The same as you guys, in my code that doesn't work inside DOM ready...
          – molokoloco
          Apr 18 '13 at 11:48










        • Justin explains why running inside doc ready causes problems. However, this answer is not a good option because it's hard to guarantee that something outside doc ready will run BEFORE doc ready. Doc.ready will not wait for scripts outside of it to run. Nothing personal, but this isn't a reliable answer.
          – AaronLS
          Sep 9 '13 at 18:55















        up vote
        63
        down vote













        Make sure to put



         $.validator.setDefaults( ignore: '' );


        NOT inside $(document).ready






        share|improve this answer


















        • 2




          Excellent answer. A link to the documentation is good for people to learn, but a straight up answer is more valuable imo. He OP was on the right track, but putting it outside of $(document).ready is the trick.
          – Kevin Zych
          Feb 2 '13 at 1:39







        • 3




          @KevinZych, Apparently, it makes absolutely no difference whether $.validator.setDefaults() is placed inside or outside of the DOM ready hander. Compare this jsFiddle to this jsFiddle.
          – Sparky
          Apr 9 '13 at 20:40











        • Interesting @Sparky, your fiddles are excellent proof. I'd have to go back and look at the code I fixed using this solution and find out why I came to the conclusion that it had to be inside of the DOM ready handler. Must have been some other reason.
          – Kevin Zych
          Apr 10 '13 at 3:26










        • The same as you guys, in my code that doesn't work inside DOM ready...
          – molokoloco
          Apr 18 '13 at 11:48










        • Justin explains why running inside doc ready causes problems. However, this answer is not a good option because it's hard to guarantee that something outside doc ready will run BEFORE doc ready. Doc.ready will not wait for scripts outside of it to run. Nothing personal, but this isn't a reliable answer.
          – AaronLS
          Sep 9 '13 at 18:55













        up vote
        63
        down vote










        up vote
        63
        down vote









        Make sure to put



         $.validator.setDefaults( ignore: '' );


        NOT inside $(document).ready






        share|improve this answer














        Make sure to put



         $.validator.setDefaults( ignore: '' );


        NOT inside $(document).ready







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 30 '16 at 9:27









        Hakam Fostok

        5,08183863




        5,08183863










        answered Apr 8 '12 at 14:05









        jerick

        63952




        63952







        • 2




          Excellent answer. A link to the documentation is good for people to learn, but a straight up answer is more valuable imo. He OP was on the right track, but putting it outside of $(document).ready is the trick.
          – Kevin Zych
          Feb 2 '13 at 1:39







        • 3




          @KevinZych, Apparently, it makes absolutely no difference whether $.validator.setDefaults() is placed inside or outside of the DOM ready hander. Compare this jsFiddle to this jsFiddle.
          – Sparky
          Apr 9 '13 at 20:40











        • Interesting @Sparky, your fiddles are excellent proof. I'd have to go back and look at the code I fixed using this solution and find out why I came to the conclusion that it had to be inside of the DOM ready handler. Must have been some other reason.
          – Kevin Zych
          Apr 10 '13 at 3:26










        • The same as you guys, in my code that doesn't work inside DOM ready...
          – molokoloco
          Apr 18 '13 at 11:48










        • Justin explains why running inside doc ready causes problems. However, this answer is not a good option because it's hard to guarantee that something outside doc ready will run BEFORE doc ready. Doc.ready will not wait for scripts outside of it to run. Nothing personal, but this isn't a reliable answer.
          – AaronLS
          Sep 9 '13 at 18:55













        • 2




          Excellent answer. A link to the documentation is good for people to learn, but a straight up answer is more valuable imo. He OP was on the right track, but putting it outside of $(document).ready is the trick.
          – Kevin Zych
          Feb 2 '13 at 1:39







        • 3




          @KevinZych, Apparently, it makes absolutely no difference whether $.validator.setDefaults() is placed inside or outside of the DOM ready hander. Compare this jsFiddle to this jsFiddle.
          – Sparky
          Apr 9 '13 at 20:40











        • Interesting @Sparky, your fiddles are excellent proof. I'd have to go back and look at the code I fixed using this solution and find out why I came to the conclusion that it had to be inside of the DOM ready handler. Must have been some other reason.
          – Kevin Zych
          Apr 10 '13 at 3:26










        • The same as you guys, in my code that doesn't work inside DOM ready...
          – molokoloco
          Apr 18 '13 at 11:48










        • Justin explains why running inside doc ready causes problems. However, this answer is not a good option because it's hard to guarantee that something outside doc ready will run BEFORE doc ready. Doc.ready will not wait for scripts outside of it to run. Nothing personal, but this isn't a reliable answer.
          – AaronLS
          Sep 9 '13 at 18:55








        2




        2




        Excellent answer. A link to the documentation is good for people to learn, but a straight up answer is more valuable imo. He OP was on the right track, but putting it outside of $(document).ready is the trick.
        – Kevin Zych
        Feb 2 '13 at 1:39





        Excellent answer. A link to the documentation is good for people to learn, but a straight up answer is more valuable imo. He OP was on the right track, but putting it outside of $(document).ready is the trick.
        – Kevin Zych
        Feb 2 '13 at 1:39





        3




        3




        @KevinZych, Apparently, it makes absolutely no difference whether $.validator.setDefaults() is placed inside or outside of the DOM ready hander. Compare this jsFiddle to this jsFiddle.
        – Sparky
        Apr 9 '13 at 20:40





        @KevinZych, Apparently, it makes absolutely no difference whether $.validator.setDefaults() is placed inside or outside of the DOM ready hander. Compare this jsFiddle to this jsFiddle.
        – Sparky
        Apr 9 '13 at 20:40













        Interesting @Sparky, your fiddles are excellent proof. I'd have to go back and look at the code I fixed using this solution and find out why I came to the conclusion that it had to be inside of the DOM ready handler. Must have been some other reason.
        – Kevin Zych
        Apr 10 '13 at 3:26




        Interesting @Sparky, your fiddles are excellent proof. I'd have to go back and look at the code I fixed using this solution and find out why I came to the conclusion that it had to be inside of the DOM ready handler. Must have been some other reason.
        – Kevin Zych
        Apr 10 '13 at 3:26












        The same as you guys, in my code that doesn't work inside DOM ready...
        – molokoloco
        Apr 18 '13 at 11:48




        The same as you guys, in my code that doesn't work inside DOM ready...
        – molokoloco
        Apr 18 '13 at 11:48












        Justin explains why running inside doc ready causes problems. However, this answer is not a good option because it's hard to guarantee that something outside doc ready will run BEFORE doc ready. Doc.ready will not wait for scripts outside of it to run. Nothing personal, but this isn't a reliable answer.
        – AaronLS
        Sep 9 '13 at 18:55





        Justin explains why running inside doc ready causes problems. However, this answer is not a good option because it's hard to guarantee that something outside doc ready will run BEFORE doc ready. Doc.ready will not wait for scripts outside of it to run. Nothing personal, but this isn't a reliable answer.
        – AaronLS
        Sep 9 '13 at 18:55











        up vote
        26
        down vote













        So I'm going to go a bit deeper in to why this doesn't work because I'm the kind of person that can't sleep at night without knowing haha. I'm using jQuery validate 1.10 and Microsoft jQuery Unobtrusive Validation 2.0.20710.0 which was published on 1/29/2013.



        I started by searching for the setDefaults method in jQuery Validate and found it on line 261 of the unminified file. All this function really does is merge your json settings in to the existing $.validator.defaults which are initialized with the ignore property being set to ":hidden" along with the other defaults defined in jQuery Validate. So at this point we've overridden ignore. Now let's see where this defaults property is being referenced at.



        When I traced through the code to see where $.validator.defaults is being referenced. I noticed that is was only being used by the constructor for a form validator, line 170 in jQuery validate unminified file.



        // constructor for validator
        $.validator = function( options, form )
        this.settings = $.extend( true, , $.validator.defaults, options );
        this.currentForm = form;
        this.init();
        ;


        At this point a validator will merge any default settings that were set and attach it to the form validator. When you look at the code that is doing the validating, highlighting, unhighlighting, etc they all use the validator.settings object to pull the ignore property. So we need to make sure if we are to set the ignore with the setDefaults method then it has to occur before the $("form").validate() is called.



        If you're using Asp.net MVC and the unobtrusive plugin, then you'll realize after looking at the javascript that validate is called in document.ready. I've also called my setDefaults in the document.ready block which is going to execute after the scripts, jquery validate and unobtrusive because I've defined those scripts in the html before the one that has the call in it. So my call obviously had no impact on the default functionality of skipping hidden elements during validation. There is a couple of options here.



        Option 1 - You could as Juan Mellado pointed out have the call outside of the document.ready which would execute as soon as the script has been loaded. I'm not sure about the timing of this since browsers are now capable of doing parallel script loading. If I'm just being over cautious then please correct me. Also, there's probably ways around this but for my needs I did not go down this path.



        Option 2a - The safe bet in my eyes is to just replace the $.validator.setDefaults( ignore: '' ); inside of the document.ready event with $("form").data("validator").settings.ignore = "";. This will modify the ignore property that is actually used by jQuery validate when doing each validation on your elements for the given form.



        Options 2b - After looking in to the code a bit more you could also use $("form").validate().settings.ignore = ""; as a way of setting the ignore property. The reason is that when looking at the validate function it checks to see if a validator object has already been stored for the form element via the $.data() function. If it finds a validator object stored with the form element then it just returns the validator object instead of creating another one.






        share|improve this answer






















        • option 2 works.
          – SSA
          Jan 31 '13 at 13:17










        • Thank you for the detailed answer!
          – davidallyoung
          Feb 20 '15 at 17:47










        • Good work as the OP answer didn't work for me in MVC 5
          – Mark Homer
          Oct 9 '15 at 14:36










        • your analysis helped me a lot in fixing one my validation issues. +1
          – Prasoon
          May 3 '16 at 6:11














        up vote
        26
        down vote













        So I'm going to go a bit deeper in to why this doesn't work because I'm the kind of person that can't sleep at night without knowing haha. I'm using jQuery validate 1.10 and Microsoft jQuery Unobtrusive Validation 2.0.20710.0 which was published on 1/29/2013.



        I started by searching for the setDefaults method in jQuery Validate and found it on line 261 of the unminified file. All this function really does is merge your json settings in to the existing $.validator.defaults which are initialized with the ignore property being set to ":hidden" along with the other defaults defined in jQuery Validate. So at this point we've overridden ignore. Now let's see where this defaults property is being referenced at.



        When I traced through the code to see where $.validator.defaults is being referenced. I noticed that is was only being used by the constructor for a form validator, line 170 in jQuery validate unminified file.



        // constructor for validator
        $.validator = function( options, form )
        this.settings = $.extend( true, , $.validator.defaults, options );
        this.currentForm = form;
        this.init();
        ;


        At this point a validator will merge any default settings that were set and attach it to the form validator. When you look at the code that is doing the validating, highlighting, unhighlighting, etc they all use the validator.settings object to pull the ignore property. So we need to make sure if we are to set the ignore with the setDefaults method then it has to occur before the $("form").validate() is called.



        If you're using Asp.net MVC and the unobtrusive plugin, then you'll realize after looking at the javascript that validate is called in document.ready. I've also called my setDefaults in the document.ready block which is going to execute after the scripts, jquery validate and unobtrusive because I've defined those scripts in the html before the one that has the call in it. So my call obviously had no impact on the default functionality of skipping hidden elements during validation. There is a couple of options here.



        Option 1 - You could as Juan Mellado pointed out have the call outside of the document.ready which would execute as soon as the script has been loaded. I'm not sure about the timing of this since browsers are now capable of doing parallel script loading. If I'm just being over cautious then please correct me. Also, there's probably ways around this but for my needs I did not go down this path.



        Option 2a - The safe bet in my eyes is to just replace the $.validator.setDefaults( ignore: '' ); inside of the document.ready event with $("form").data("validator").settings.ignore = "";. This will modify the ignore property that is actually used by jQuery validate when doing each validation on your elements for the given form.



        Options 2b - After looking in to the code a bit more you could also use $("form").validate().settings.ignore = ""; as a way of setting the ignore property. The reason is that when looking at the validate function it checks to see if a validator object has already been stored for the form element via the $.data() function. If it finds a validator object stored with the form element then it just returns the validator object instead of creating another one.






        share|improve this answer






















        • option 2 works.
          – SSA
          Jan 31 '13 at 13:17










        • Thank you for the detailed answer!
          – davidallyoung
          Feb 20 '15 at 17:47










        • Good work as the OP answer didn't work for me in MVC 5
          – Mark Homer
          Oct 9 '15 at 14:36










        • your analysis helped me a lot in fixing one my validation issues. +1
          – Prasoon
          May 3 '16 at 6:11












        up vote
        26
        down vote










        up vote
        26
        down vote









        So I'm going to go a bit deeper in to why this doesn't work because I'm the kind of person that can't sleep at night without knowing haha. I'm using jQuery validate 1.10 and Microsoft jQuery Unobtrusive Validation 2.0.20710.0 which was published on 1/29/2013.



        I started by searching for the setDefaults method in jQuery Validate and found it on line 261 of the unminified file. All this function really does is merge your json settings in to the existing $.validator.defaults which are initialized with the ignore property being set to ":hidden" along with the other defaults defined in jQuery Validate. So at this point we've overridden ignore. Now let's see where this defaults property is being referenced at.



        When I traced through the code to see where $.validator.defaults is being referenced. I noticed that is was only being used by the constructor for a form validator, line 170 in jQuery validate unminified file.



        // constructor for validator
        $.validator = function( options, form )
        this.settings = $.extend( true, , $.validator.defaults, options );
        this.currentForm = form;
        this.init();
        ;


        At this point a validator will merge any default settings that were set and attach it to the form validator. When you look at the code that is doing the validating, highlighting, unhighlighting, etc they all use the validator.settings object to pull the ignore property. So we need to make sure if we are to set the ignore with the setDefaults method then it has to occur before the $("form").validate() is called.



        If you're using Asp.net MVC and the unobtrusive plugin, then you'll realize after looking at the javascript that validate is called in document.ready. I've also called my setDefaults in the document.ready block which is going to execute after the scripts, jquery validate and unobtrusive because I've defined those scripts in the html before the one that has the call in it. So my call obviously had no impact on the default functionality of skipping hidden elements during validation. There is a couple of options here.



        Option 1 - You could as Juan Mellado pointed out have the call outside of the document.ready which would execute as soon as the script has been loaded. I'm not sure about the timing of this since browsers are now capable of doing parallel script loading. If I'm just being over cautious then please correct me. Also, there's probably ways around this but for my needs I did not go down this path.



        Option 2a - The safe bet in my eyes is to just replace the $.validator.setDefaults( ignore: '' ); inside of the document.ready event with $("form").data("validator").settings.ignore = "";. This will modify the ignore property that is actually used by jQuery validate when doing each validation on your elements for the given form.



        Options 2b - After looking in to the code a bit more you could also use $("form").validate().settings.ignore = ""; as a way of setting the ignore property. The reason is that when looking at the validate function it checks to see if a validator object has already been stored for the form element via the $.data() function. If it finds a validator object stored with the form element then it just returns the validator object instead of creating another one.






        share|improve this answer














        So I'm going to go a bit deeper in to why this doesn't work because I'm the kind of person that can't sleep at night without knowing haha. I'm using jQuery validate 1.10 and Microsoft jQuery Unobtrusive Validation 2.0.20710.0 which was published on 1/29/2013.



        I started by searching for the setDefaults method in jQuery Validate and found it on line 261 of the unminified file. All this function really does is merge your json settings in to the existing $.validator.defaults which are initialized with the ignore property being set to ":hidden" along with the other defaults defined in jQuery Validate. So at this point we've overridden ignore. Now let's see where this defaults property is being referenced at.



        When I traced through the code to see where $.validator.defaults is being referenced. I noticed that is was only being used by the constructor for a form validator, line 170 in jQuery validate unminified file.



        // constructor for validator
        $.validator = function( options, form )
        this.settings = $.extend( true, , $.validator.defaults, options );
        this.currentForm = form;
        this.init();
        ;


        At this point a validator will merge any default settings that were set and attach it to the form validator. When you look at the code that is doing the validating, highlighting, unhighlighting, etc they all use the validator.settings object to pull the ignore property. So we need to make sure if we are to set the ignore with the setDefaults method then it has to occur before the $("form").validate() is called.



        If you're using Asp.net MVC and the unobtrusive plugin, then you'll realize after looking at the javascript that validate is called in document.ready. I've also called my setDefaults in the document.ready block which is going to execute after the scripts, jquery validate and unobtrusive because I've defined those scripts in the html before the one that has the call in it. So my call obviously had no impact on the default functionality of skipping hidden elements during validation. There is a couple of options here.



        Option 1 - You could as Juan Mellado pointed out have the call outside of the document.ready which would execute as soon as the script has been loaded. I'm not sure about the timing of this since browsers are now capable of doing parallel script loading. If I'm just being over cautious then please correct me. Also, there's probably ways around this but for my needs I did not go down this path.



        Option 2a - The safe bet in my eyes is to just replace the $.validator.setDefaults( ignore: '' ); inside of the document.ready event with $("form").data("validator").settings.ignore = "";. This will modify the ignore property that is actually used by jQuery validate when doing each validation on your elements for the given form.



        Options 2b - After looking in to the code a bit more you could also use $("form").validate().settings.ignore = ""; as a way of setting the ignore property. The reason is that when looking at the validate function it checks to see if a validator object has already been stored for the form element via the $.data() function. If it finds a validator object stored with the form element then it just returns the validator object instead of creating another one.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 9 '13 at 19:31









        AaronLS

        26.7k14115171




        26.7k14115171










        answered Jan 29 '13 at 3:03









        JustinMichaels

        1,012712




        1,012712











        • option 2 works.
          – SSA
          Jan 31 '13 at 13:17










        • Thank you for the detailed answer!
          – davidallyoung
          Feb 20 '15 at 17:47










        • Good work as the OP answer didn't work for me in MVC 5
          – Mark Homer
          Oct 9 '15 at 14:36










        • your analysis helped me a lot in fixing one my validation issues. +1
          – Prasoon
          May 3 '16 at 6:11
















        • option 2 works.
          – SSA
          Jan 31 '13 at 13:17










        • Thank you for the detailed answer!
          – davidallyoung
          Feb 20 '15 at 17:47










        • Good work as the OP answer didn't work for me in MVC 5
          – Mark Homer
          Oct 9 '15 at 14:36










        • your analysis helped me a lot in fixing one my validation issues. +1
          – Prasoon
          May 3 '16 at 6:11















        option 2 works.
        – SSA
        Jan 31 '13 at 13:17




        option 2 works.
        – SSA
        Jan 31 '13 at 13:17












        Thank you for the detailed answer!
        – davidallyoung
        Feb 20 '15 at 17:47




        Thank you for the detailed answer!
        – davidallyoung
        Feb 20 '15 at 17:47












        Good work as the OP answer didn't work for me in MVC 5
        – Mark Homer
        Oct 9 '15 at 14:36




        Good work as the OP answer didn't work for me in MVC 5
        – Mark Homer
        Oct 9 '15 at 14:36












        your analysis helped me a lot in fixing one my validation issues. +1
        – Prasoon
        May 3 '16 at 6:11




        your analysis helped me a lot in fixing one my validation issues. +1
        – Prasoon
        May 3 '16 at 6:11










        up vote
        8
        down vote













        Just added ignore: in the specific page for the specific form, this solution worked for me.



        $("#form_name").validate(
        ignore: ,
        onkeyup: false,
        rules:
        ,
        highlight:false,
        );





        share|improve this answer


























          up vote
          8
          down vote













          Just added ignore: in the specific page for the specific form, this solution worked for me.



          $("#form_name").validate(
          ignore: ,
          onkeyup: false,
          rules:
          ,
          highlight:false,
          );





          share|improve this answer
























            up vote
            8
            down vote










            up vote
            8
            down vote









            Just added ignore: in the specific page for the specific form, this solution worked for me.



            $("#form_name").validate(
            ignore: ,
            onkeyup: false,
            rules:
            ,
            highlight:false,
            );





            share|improve this answer














            Just added ignore: in the specific page for the specific form, this solution worked for me.



            $("#form_name").validate(
            ignore: ,
            onkeyup: false,
            rules:
            ,
            highlight:false,
            );






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 27 '13 at 5:24









            Benno

            5,47722029




            5,47722029










            answered Nov 27 '13 at 4:58









            Kiran

            521618




            521618




















                up vote
                6
                down vote













                This worked for me within an ASP.NET site.
                To enable validation on some hidden fields use this code



                $("form").data("validator").settings.ignore = ":hidden:not(#myitem)";



                To enable validation for all elements of form use this one
                $("form").data("validator").settings.ignore = "";



                Note that use them within $(document).ready(function() )






                share|improve this answer
























                  up vote
                  6
                  down vote













                  This worked for me within an ASP.NET site.
                  To enable validation on some hidden fields use this code



                  $("form").data("validator").settings.ignore = ":hidden:not(#myitem)";



                  To enable validation for all elements of form use this one
                  $("form").data("validator").settings.ignore = "";



                  Note that use them within $(document).ready(function() )






                  share|improve this answer






















                    up vote
                    6
                    down vote










                    up vote
                    6
                    down vote









                    This worked for me within an ASP.NET site.
                    To enable validation on some hidden fields use this code



                    $("form").data("validator").settings.ignore = ":hidden:not(#myitem)";



                    To enable validation for all elements of form use this one
                    $("form").data("validator").settings.ignore = "";



                    Note that use them within $(document).ready(function() )






                    share|improve this answer












                    This worked for me within an ASP.NET site.
                    To enable validation on some hidden fields use this code



                    $("form").data("validator").settings.ignore = ":hidden:not(#myitem)";



                    To enable validation for all elements of form use this one
                    $("form").data("validator").settings.ignore = "";



                    Note that use them within $(document).ready(function() )







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jun 10 '16 at 6:19









                    angela.mirjalili

                    11125




                    11125




















                        up vote
                        0
                        down vote













                        This is working for me.



                        jQuery("#form_name").validate().settings.ignore = "";





                        share|improve this answer
























                          up vote
                          0
                          down vote













                          This is working for me.



                          jQuery("#form_name").validate().settings.ignore = "";





                          share|improve this answer






















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            This is working for me.



                            jQuery("#form_name").validate().settings.ignore = "";





                            share|improve this answer












                            This is working for me.



                            jQuery("#form_name").validate().settings.ignore = "";






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 16 '17 at 2:32









                            Waqas Bukhary

                            2,92922540




                            2,92922540




















                                up vote
                                -12
                                down vote













                                Just find the text ignore: ":hidden" in your jquery validation file and comment it.
                                After comment this it will never loss any hidden elements to validate...



                                Thanks






                                share|improve this answer
















                                • 5




                                  Never a good idea to just randomly comment out code in a third party library.
                                  – Jacques
                                  Oct 12 '15 at 13:45














                                up vote
                                -12
                                down vote













                                Just find the text ignore: ":hidden" in your jquery validation file and comment it.
                                After comment this it will never loss any hidden elements to validate...



                                Thanks






                                share|improve this answer
















                                • 5




                                  Never a good idea to just randomly comment out code in a third party library.
                                  – Jacques
                                  Oct 12 '15 at 13:45












                                up vote
                                -12
                                down vote










                                up vote
                                -12
                                down vote









                                Just find the text ignore: ":hidden" in your jquery validation file and comment it.
                                After comment this it will never loss any hidden elements to validate...



                                Thanks






                                share|improve this answer












                                Just find the text ignore: ":hidden" in your jquery validation file and comment it.
                                After comment this it will never loss any hidden elements to validate...



                                Thanks







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jun 20 '13 at 12:29









                                user835525

                                9




                                9







                                • 5




                                  Never a good idea to just randomly comment out code in a third party library.
                                  – Jacques
                                  Oct 12 '15 at 13:45












                                • 5




                                  Never a good idea to just randomly comment out code in a third party library.
                                  – Jacques
                                  Oct 12 '15 at 13:45







                                5




                                5




                                Never a good idea to just randomly comment out code in a third party library.
                                – Jacques
                                Oct 12 '15 at 13:45




                                Never a good idea to just randomly comment out code in a third party library.
                                – Jacques
                                Oct 12 '15 at 13:45





                                protected by Sparky May 31 '14 at 22:40



                                Thank you for your interest in this question.
                                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                Would you like to answer one of these unanswered questions instead?



                                Popular posts from this blog

                                𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                                Edmonton

                                Crossroads (UK TV series)