简体   繁体   中英

jQuery validation & ignore field

I have a form with id myform and two fields (dates) with date class. I would like to avoid jquery.validation (unobstrusive jquery validation on ASP .NET MVC3) for these two fields. I tried :

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

However it doesn't work, I always have an error ( Please enter a valid date. ).

I need help please !

Thanks,

Ed

It works fine to me as described at the documentation http://jqueryvalidation.org/validate

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

And, for multiple field use:

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

根据This Doc ,你需要ignoreTitle

For anyone who is trying this alongside jquery.validate.unobtrusive , you may find it's ignoring all options passed into $("#myform").validate() and you'll have to set them on the object instead:

$('#myform').validate().settings.ignore = ".date";
$('#myform').valid();

The Unobtrusive plugin calls validate() when the document loads, which sets the options to defaults. A validator will then be created and cached, and any further calls to validate() will ignore new options and return the cached validator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM