MVC 3 unobtrusive validation - conditionally disable/enable validation

梦想的初衷 提交于 2019-11-29 14:10:29

You can set up the jQuery validator that's processing your unobtrusive validation to ignore hidden elements:

jQuery.validator.defaults.ignore = ":hidden";

// the line above is outside any $(document).ready(...) or similar
$(document).ready(function(){
    ...
});
...
Rob

So it seems that this is the answer to my question (I went hunting again on Google hard to search for things that didn't relate to "hidden" fields):

https://stackoverflow.com/a/7673985/491950

e.g.

$("#height-container input[type='text']").attr("disabled", "disabled");

Thanks for your answers.

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