2010-05-20 79 views

回答

2

伊姆蘭俾路支的博客有你的答案:

http://weblogs.asp.net/imranbaloch/archive/2010/06/20/disabling-client-side-validation-for-disabled-input-controls-in-asp-net-mvc.aspx

它涉及到一個定製MicrosoftMvcValidation.debug.js

更改此:

if (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(errorMessage)) { 
    Array.add(errors, errorMessage); 
} 

爲此:

var inptEl = $get(context.fieldContext.elements[0].id); 
if (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(errorMessage) && !inptEl.disabled) { 
    Array.add(errors, errorMessage); 
} 
else 
    Sys.UI.DomElement.removeCssClass(inptEl, Sys.Mvc.FieldContext._inputElementErrorCss);