Hi,
This is my first time using Adobe to write any validation script. Could someone provide an example script that would navigate the user to a text field and only let them fill in this text field if they check a Yes check box?
Thanks
OK, here's what I would suggest as the Mouse Up script (not Validate script) for the check box:
// Mouse Up script for check box
(function () {
// Get a reference to the text field
var f = getField("text1");
// Reset the text field
f.value = f.defaultValue;
// Set the focus to the text field if check box is selected
if (event.target.value !== "Off") {
f.readonly = false;
f.setFocus();
} else {
f.readonly = true;
}
})();
Replace "text1" in the code above with the actual name of the text field you want to control.
The code you provided partially works how I wanted it to. Is there a way to make the text field unclickable until the user checks the yes box? Also, if the no box is checked I wanted it to clear any info in the text box and make it unclickable again. So basically there can only be info in the text box after the yes box has been checked.
THANKS!
I didn't realize you had another check box. You can place the same code (below) in the Mouse Up event of both check boxes:
// Mouse Up script for check box
(function () {
// Get a reference to the text field
var f = getField("text1");
// Reset the text field
f.value = f.defaultValue;
// Set the focus to the text field if check box is selected
if (event.target.value === "Yes") {
f.readonly = false;
f.setFocus();
} else {
f.readonly = true;
}
})();
This assumes that the export value of the Yes check box is "Yes", and that the export value of the No check box is something else. The code set the field to read-only if the Yes check box is not selected, which makes makes it unclickable. The code also resets the text field whenever the script it called.
North America
Europe, Middle East and Africa
Asia Pacific