$(document).ready(function () {
try{
if (typeof (Page_Validators) == 'undefined') return;
// Create new DOB validator
var dobValidator = document.createElement('span');
dobValidator.style.display = "none";
dobValidator.id = "dobValidator";
dobValidator.controltovalidate = "new_dateofbirth";
dobValidator.errormessage = "<a href='#new_dateofbirth_label'>Date of birth should be in past.</a>";
dobValidator.validationGroup = "";
dobValidator.initialvalue = "";
dobValidator.evaluationfunction = function () {
var dobValue = $("#new_dateofbirth").val();
var dob=new Date(dobValue);
var today = new Date();
if (dob > today) {
return false;
}
return true;
};
// Add the dobValidator to Web Page’s validators array
Page_Validators.push(dobValidator);
// Attach event handler of the validation summary link
$("a[href='#new_dateofbirth_label']").on("click", function () { scrollToAndFocus('new_dateofbirth_label','new_dateofbirth');
});
}
catch(e)
{
alert("Error during DOB validation – "+e.description);
}
});