Post Views: 2,792
//---------------------------------------------------------------------
//REQUIREMENT : the minimum age should be more than 18 years validation.
//-----------------------------------------------------------------------
function onChangeDOB (executionContext) {
var formContext = executionContext.getFormContext();
var birthDate = formContext.getAttribute("birthdate").getValue();
var today = new Date();
var validMinDate = new Date(
today.getFullYear()-18,
today.getMonth(),
today.getDate() ,
today.getHours(),
today.getMinutes());
var birthDateFieldControl = formContext.getControl("birthdate");
if(birthDate>validMinDate){
birthDateFieldControl.setNotification("Minimum Age must be 18 years. Choose correct Birthdate", "BDATE");
}
else{
birthDateFieldControl.clearNotification("BDATE");
}
};