Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have managed to get this working in webforms by overriding ValidatorUpdateDisplay. Webforms does not use jquery unobtrusive validation or validate it uses WebUIValidation.js. I have spent all day on this its been driving me crazy. In the end i thought it best to override existing functions. Coded based on: <a href="http://blog.benmcevoy.com.au/classing-invalid-elements-with-webforms-validation" rel="nofollow">http://blog.benmcevoy.com.au/classing-invalid-elements-with-webforms-validation</a></p> <p>See code below. I hope this helps someone else. Please feel free to comment if you can make the code better.</p> <pre><code> (function ($) { if (window.ValidatorUpdateDisplay) { var proxied = window.ValidatorUpdateDisplay; window.ValidatorUpdateDisplay = function () { onBefore(arguments); var result = proxied.apply(this, arguments); onAfter(arguments); return result; }; var onBefore = function (arguments) { }; var onAfter = function (arguments) { var control = document.getElementById(arguments[0].controltovalidate); var validators = control.Validators; var isValid = true; for (var i = 0; i &lt; validators.length; i++) { if (!validators[i].isvalid) { isValid = false; break; } } if (isValid) { var group = $(control).closest('div.control-group'); if (group.find('span.field-validation-error').length &gt; 0) { group.removeClass('error'); group.addClass('success'); } } else { var group = $(control).closest('div.control-group'); if (group.find('span.field-validation-error').length &gt; 0) { group.removeClass('success'); group.addClass('error'); } } }; } })(jQuery); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload