views:

247

answers:

0

My MVC validation is failing on disabled form fields - saying that they are required, even though these disabled input fields have values set.

I read this http://weblogs.asp.net/imranbaloch/archive/2010/06/20/disabling-client-side-validation-for-disabled-input-controls-in-asp-net-mvc.aspx which explains how to modify the MicrosoftMvcValidation.debug.js file to disable validation on disabled form fields... however, I'm using the non debug version MicrosoftMvcValidation.js - which is very different.

I would prefer to continue validating these disabled fields, which are [Required] in my model, and do indeed have values set to them via javascript.

Edit: After reading this answer to another question: http://stackoverflow.com/questions/2653432/asp-net-mvc-1-model-binding-with-disabled-textbox/2653645#2653645 disabling is going to cause issues since those fields do not get posted. I could set them to readonly, however, my combobox is selectable in that state.

I'd prefer not to add a hidden form field for every field that may be disabled.