Disable validation for an element with jQuery Unobtrusive Validation

会有一股神秘感。 提交于 2019-11-28 20:47:18

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.

I think this will help.

<div class="editor-field">
       @{ Html.EnableClientValidation(false); }
       @Html.TextBoxFor(m => m.BatchId, new { @class = "k-textbox" })
       @{ Html.EnableClientValidation(true); }
</div>

I think you need to write a custom validation attribute and then handle the data yourself in JQuery.

See this article: http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!