简体   繁体   中英

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. 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');

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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