Check box if Child is 10 or Older
I am working in Acrobat DC and I have a field for a child’s date of birth, ChildDOB. Later in the form I have a field, Age, that calculates the child’s age (see below). Later yet in the form I have a check box, CBOver10, that I want to have automatically checked if the child is 10 years of age or older and of course remain unchecked if the child is 9 years of age or younger.
This is my coding for the Age field.
var dob = util.scand("mm/dd/yyyy", this.getField("ChildDOB").valueAsString);
if (dob != null) {
var today = new Date();
var age = today.getFullYear() - dob.getFullYear();
var m = today.getMonth() - dob.getMonth();
if (m < 0 || (m === 0 && today.getDate() < dob.getDate())) {
age--;
}
event.value = age;
}
else {
event.value = "";
}
I’m not sure how to and what the coding would be to have CBOver10 checked automatically if the child is 10 years of age or older.
Thanks for your help.
