Copy link to clipboard
Copied
I have a checkbox with the name "Completed High School?", a text field with the name "Number of Years Completed", and radio button group called "High School Credentials". Ideally, someone would check the checkbox first and then enter the number of years completed and select a radio button option second. But in case they overlook the checkbox and go straight for the other fields, I would like the checkbox to be checked automatically, as soon as text is entered in the field, or as soon as a radio button option is selected.
The part where the checkbox gets checked when you select a radio button option is working. It's the text field that's giving me trouble.
I placed this custom validation script on the text field:
if (event.target.value != "") this.getField("Completed High School?").checkThisBox(0, true);
But that doesn't work like I expected it to; it does nothing at all.
I also have this mouseup action on the checkbox:
if (event.target.value == "Off") {
this.getField("Number of Years Completed").value = "";
this.getField("High School Credentials").value = "Off";
}
Copy link to clipboard
Copied
Ahh, I think I figured it out. For reasons that are still not clear to me, I should have written event.value instead of event.target.value.
Copy link to clipboard
Copied
That's because in the Validation event event.target.value refers to the field's old value (because the new one has not been accepted yet), while event.value refers to its new value, the one the user just entered.