Using MicrosoftMvcValidation.js for client side validation, is there an easy way of programatically (in javascript) turning the validation off and on for particular fields?
Is it possible for example to use jquery to bind/unbind the events?
Using MicrosoftMvcValidation.js for client side validation, is there an easy way of programatically (in javascript) turning the validation off and on for particular fields?
Is it possible for example to use jquery to bind/unbind the events?
Imran Baloch's Blog has your answer:
It involves a customization to MicrosoftMvcValidation.debug.js
Change this:
if (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(errorMessage)) {
Array.add(errors, errorMessage);
}
To this:
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);