Disable validation for an element with jQuery Unobtrusive Validation

后端 未结 3 826
忘掉有多难
忘掉有多难 2020-12-14 11:05

I am generating a list of elements on a page, and they all have validators attached to them. When I look in the HTML source, I see something like:



        
3条回答
  •  青春惊慌失措
    2020-12-14 11:49

    I actually found a solution that fits my needs better. I can do the following:

    $(function() {
        var settngs = $.data($('form')[0], 'validator').settings;
        settngs.ignore = ".ignore";
    });
    

    And with that i can 'toggle' any element that i want by adding or removing the classname ignore from an element.

提交回复
热议问题