Copy link to clipboard
Copied
I have a script that checks a box when a person's age is within 10 years of another person. The script works fine, but the box is checked by default until the information is filled in. This confuses some people, so I'm trying to set the default to unchecked. Here is the script:
var fieldT = this.getField("Checkbox 1");
var x = this.getField("Age").valueAsString;
age = event.value;
if (Math.abs(Number(x)-Number(age))<=10){
fieldT.checkThisBox(0,true);
}
else
{
fieldT.checkThisBox(0,false);
}
I appreciate any and all assistance. Thanks!
Copy link to clipboard
Copied
Do you mean when the Age field is empty?
Copy link to clipboard
Copied
Yes, sorry for not clarifying.
Copy link to clipboard
Copied
Change this line:
if (Math.abs(Number(x)-Number(age))<=10){
To:
if (x!="" && Math.abs(Number(x)-Number(age))<=10){