jQuery Validate unobtrusive - Enable validation for hidden fields -
i use asp.net mvc 5, jquery validate unobtrusive, jquery validate 1.13 version. have searched answer, although problem have solve,but want know method.
$.validator.setdefaults({ ignore: [] }); //valid $("#form1").data("validator").settings.ignore = []; //invalid,all input validate invalid $("#form1").data("validator").settings.debug = true;//valid,if use method,debug ture model open, why?
if put code in $(document).ready. code useless
how enable validation hidden fields 1 form?
instead of enabling validation hidden fields , better enable validation ones want.
you can assigning class hidden fields want validate , using following code.
// add special-hidden class hidden fields want validate. var validator = $("#formid").validate({ rules: rules }); // line basicially tells validator ignore hidden fields apart ones class special-hidden validator.settings.ignore = ':hidden:not([class~=special-hidden])';
if want enable validation hidden fields , use
validator.settings.ignore = '';
Comments
Post a Comment