jQuery disable rule validation on a single field

前端 未结 5 2017
说谎
说谎 2020-11-28 04:35

I am using MVC to create forms that are generated at runtime. For validation, I am trying my hand at the jQuery validation library which is very convenient to use. I have th

5条回答
  •  没有蜡笔的小新
    2020-11-28 05:15

    I had a better time with $('.multiselect').rules('remove');

    in my case for whatever reason adding .cancel or .data-val-ignore to both the $.validator.setDefaults and $('.multiselect') did not fix it.

    I also tried

    $('select[multiple][data-val]').removeAttr('data-val').removeAttr('data-val-number').addClass('data-val-ignore').validate({ ignore: "[multiple]" });
    $.validator.setDefaults({ ignore: ":hidden,:disabled,.data-val-ignore" });
    $('.multiselect').closest('form').data('validator').settings.ignore = ":hidden,:disabled,.data-val-ignore, .data-val-ignore *";
    $('.multiselect').data('validator').settings.ignore = "[multiselect]"
    

    each of those... and combinations of them

    my jquery.validate.js was

    /*! jQuery Validation Plugin - v1.11.0 - 2/4/2013
    * https://github.com/jzaefferer/jquery-validation
    * Copyright (c) 2013 Jörn Zaefferer; Licensed MIT */
    

    jquery was

    jQuery JavaScript Library v1.9.1 - Date: 2013-2-4

提交回复
热议问题