简体   繁体   English

禁用启用非侵入式验证mvc

[英]disable enable unobtrusive validation mvc

I have a wizard which contains a very large form. 我有一个包含很大表格的向导。 The wizard has an area where the user chooses one of two options which shows and hides a div with other input elements. 向导具有一个区域,用户可以在其中选择两个选项之一,该选项显示和隐藏具有其他输入元素的div。 The problem is that the hidden elements are being validated and i need to turn validation off on those certain elements. 问题是隐藏的元素正在被验证,我需要对那些特定元素关闭验证。

I've tried: $('.data-panel').find('input[type="text"], textarea, select').attr('disabled', 'disabled'); 我试过了:$('。data-panel')。find('input [type =“ text”],textarea,select')。attr('disabled','disabled');

as state in this thread, but it will still validate those input elements. 作为该线程中的状态,但仍将验证那些输入元素。 MVC3 unobtrusive validation: how to remove/re-attach validation from a group of elements? MVC3非侵入式验证:如何从一组元素中删除/重新附加验证?

I thought about injecting/remove a partial view, but those elements won't validate when they need to be validated. 我曾考虑过注入/删除局部视图,但是这些元素在需要验证时不会生效。

I'm opening for any work arounds. 我正准备进行任何工作。 Thanks! 谢谢!

To disable: 禁用:

$('.data-panel').find('input[type="text"], textarea, select').prop('disabled', true);

To enable: 启用:

$('.data-panel').find('input[type="text"], textarea, select').prop('disabled', false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM