Hello
I have a form and there are two fields first one Date of birth ,second one Base Enum Age stage(adult , mature).
I want to know how I can change the Base Enum filed when user input his date of birth.
Thank you
Hi,
You can create a on change event on your birthday field with the following code:
function birthdayOnChange(executionContext){ var formContext = executionContext.getFormContext(); var birthday = formContext.getAttribute("birthday").getValue(); if(birthday !== null){ var now = new Date(); var age = now.getFullYear() - birthday.getFullYear(); var m = now.getMonth() - birthday.getMonth(); if (m < 0 || (m === 0 && now.getDate() < birthday.getDate())) { age--; } if(age>=18){ formContext.getAttribute("ageStage").setValue(ageStageValue); }else{ formContext.getAttribute("ageStage").setValue(ageStageValue); } } }
Adis
136
Super User 2025 Season 1
Sohail Ahmed
81
Jonas "Jones" Melgaard
77
Super User 2025 Season 1