Skip to content

Instantly share code, notes, and snippets.

@pc-pdx
Created February 9, 2018 21:56
Show Gist options
  • Save pc-pdx/b299169dc32c08982577068f1c342375 to your computer and use it in GitHub Desktop.
Save pc-pdx/b299169dc32c08982577068f1c342375 to your computer and use it in GitHub Desktop.
function doFormValidation(validationGroup, errorclass) {
if (typeof Page_IsValid != "boolean") {
return true; // ASP.NET client side validation not properly loaded
}
if (Page_IsValid == false) {
if (Page_Validators) {
var invalidArrayIndex = 0;
var invalidArray = Array();
for (var index = 0; index < Page_Validators.length; index++) {
var validator = Page_Validators[index];
var controlName = validator.controltovalidate;
if (controlName == undefined) { continue; }
var validatorElement = $(validator);
var controlElement = $("#" + controlName);
if (validator.isvalid == false) {
var $parent = $(controlElement).parents().filter('li:first');
if ($parent.find('span.error').length == 0) {
$parent.addClass(errorclass);
$parent.append('<span class="error">error</span>');
var offT = $parent.position().top;
$('.contact-info').find('span.error:last').css({ top: offT + 17 + 'px' });
}
invalidArray[invalidArrayIndex] = controlName;
invalidArrayIndex = invalidArrayIndex + 1;
} else {
validatorElement.hide();
validatorElement.html("");
if (jQuery.inArray(controlName, invalidArray) == -1)
$(controlElement).parents().filter('li:first').removeClass(errorclass)
.find('span.error').remove(); //Find Parent LI and remove error class |DCVW
}
}
}
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment