1 2function UpgradeASPNETValidation() { 3 if (typeof (Page_ClientValidate) != "undefined") { 4 AspValidatorUpdateDisplay = ValidatorUpdateDisplay; 5 ValidatorUpdateDisplay = NicerValidatorUpdateDisplay; 6 AspValidatorValidate = ValidatorValidate; 7 ValidatorValidate = NicerValidatorValidate; 8 9 // Remove the error class on each control group before validating 10 // Store a reference to the ClientValidate function 11 var origValidate = Page_ClientValidate; 12 // Override with our custom version 13 Page_ClientValidate = function (validationGroup) { 14 // Clear all the validation classes for this validation group 15 for (var i = 0; i < Page_Validators.length; i++) { 16 if ((typeof (Page_Validators[i].validationGroup) == 'undefined' && !validationGroup) || 17 Page_Validators[i].validationGroup == validationGroup) { 18 $("#" + Page_Validators[i].controltovalidate).parents('.form-group').each(function () { 19 $(this).removeClass('has-error'); 20 }); 21 } 22 } 23 // Call the original function 24 origValidate(validationGroup); 25 }; 26 } 27} 28 29function NicerValidatorUpdateDisplay(val) { 30 AspValidatorUpdateDisplay(val); 31 if ((typeof (val.enabled) == "undefined" || val.enabled != false)/* && IsValidationGroupMatch(val, AspValidatorValidating)*/) { 32 if (!val.isvalid) { 33 $('#' + val.controltovalidate).parents('.form-group:first').addClass('has-error'); 34 //$('#' + val.controltovalidate).parents('.form-row:first').children('.control-label:first').addClass('text-danger'); 35 } else { 36 if (IsControlValid(val.controltovalidate)) { 37 $('#' + val.controltovalidate).parents('.form-group:first').removeClass('has-error'); 38 //$('#' + val.controltovalidate).parents('.form-row:first').children('.control-label:first').removeClass('text-danger'); 39 } 40 } 41 } 42} 43 44function IsControlValid(controlName) { 45 var state = true; 46 for (i = 0; i < window.Page_Validators.length; i++) { 47 if (window.Page_Validators[i].controltovalidate == controlName && !window.Page_Validators[i].isvalid) { 48 state = false; 49 } 50 } 51 return state; 52} 53 54function NicerValidatorValidate(val, validationGroup, event) { 55 AspValidatorValidating = validationGroup; 56 AspValidatorValidate(val, validationGroup, event); 57} 58 59// Call UpgradeASPNETValidation after the page has loaded so that it 60// runs after the standard ASP.NET scripts. 61$(function () { 62 UpgradeASPNETValidation(); 63}); 64 65function validatorSetState(validatorId, state) { 66 var validator = document.getElementById(validatorId); 67 validator.enabled = state; 68 ValidatorUpdateDisplay(validator); 69}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.