开发者

mvc 3: disabling validation on selected fields

开发者 https://www.devze.com 2023-02-16 07:27 出处:网络
I have a need to disable validation on certain fields when certain events occur, so based on the suggestion in this thread: 开发者_如何转开发jQuery disable rule validation on a single field

I have a need to disable validation on certain fields when certain events occur, so based on the suggestion in this thread: 开发者_如何转开发jQuery disable rule validation on a single field

I tried this:

$("form").validate({
   ignore: ".ignore"
})

But I am finding that it disables all validation on all fields, not just those with class="ignore".

Am I doing something wrong with this?


How about trying:

$('#CompaniesGridform').validate({
    ignore: ":disabled"
});


I'm currently doing it something like this

<button id="Submit" type="submit">Submit</button>

<script type="text/javascript">
    $("#Submit").on("click", function () {
        var validator = $("form").data('validator');
        validator.settings.ignore = ".ignore";
    });
</script>

Switch out .ignore for any jQuery selector or chain them up like ".ignore, input[type=hidden]"

0

精彩评论

暂无评论...
验证码 换一张
取 消