// Get the birthdate input
var birthdateInput = this.getQuestionInput('Q4'); // Replace 'Q4' with the actual Question ID of your birthdate question
// Calculate the age
var today = new Date();
var birthdate = new Date(birthdateInput);
var age = today.getFullYear() - birthdate.getFullYear();
var m = today.getMonth() - birthdate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthdate.getDate())) {
age--;
}
// Output the age
console.log(age); // You can replace 'console.log' with any other method of outputting the age, such as displaying it on the page or storing it in a hidden question
});
Can I auto-populate age Q4, from the question Date of Birth Q3?
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
