Posts

Showing posts from December, 2010

Hooking into ASP Client Side Validation

The Problem: The ASP Validators are hard to style. The Validators only render a <span> with the error information. What if you want to display the complete div around the control to be red when an error occures? This is likely not possible with the standard asp validators. What you can do is o write a decorator in javascript. The function which displays the errormessages is the "ValidatorUpdateDisplay" method. 1: /** 2: * @requires JQuery 1.4.x 3: */ 4: var Biggy = {}; 5: 6: Biggy.Validator = { 7: /** 8: * Decorator for the ms validator update function 9: * 10: * @param {orig_fn} Function 11: * The function to decorate 12: * @return Function 13: * The decorated fucntion 14: */ 15: UpdateDisplayDecorator : function(orig_fn) { 16: return function(){ 17: var originalfunc = orig_fn.apply(this, arguments); 18: Biggy.Validator.UpdateParentDisplay( arguments[0] ); 19: return originalfunc; 20: };