Last active
February 11, 2017 16:35
-
-
Save doeringp/529cc6f961c936fee629c285feec0a28 to your computer and use it in GitHub Desktop.
Hook into the ASP.NET client-side validation to apply some styles to the control if the validation fails.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
if (typeof (window.ValidatorUpdateDisplay) === "undefined" || window.ValidatorUpdateDisplay == null) { | |
console.warn("The ValidatorUpdateDisplay() method isn't defined. Can't inject custom validation."); | |
} else { | |
var aspUpdateDisplay = window.ValidatorUpdateDisplay; | |
window.ValidatorUpdateDisplay = function (n) { | |
var $controlToValidate = $(document.getElementById(n.controltovalidate)); | |
if (n.isvalid) { | |
$controlToValidate.removeClass("invalid"); | |
} else { | |
$controlToValidate.addClass("invalid"); | |
} | |
// Call the original ValidatorUpdateDisplay()-method. | |
aspUpdateDisplay(n); | |
}; | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment