top of page

ACRO PDF - How to have a checkbox selection to reset and make read only specific text fields

Updated: Mar 29

Summary

You may have a PDF form where there is a mutually exclusive Yes and No checkbox pair that when the No checkbox is selected, several associated fields need to be reset and become read only with the ability skip the read only fields in the tab order.

What you want the script to do

For the Yes checkbox, the first part of the script resets the mutually exclusive No checkbox and the second part sets the associated fields read only property to false. Allowing entry into those fields.

For the No checkbox, the first part of the script resets the mutually exclusive Yes checkbox and the second sets the associated fields to be reset and to be read only with a line of script that sets focus to the next field that is not read only.


Two Methods – Hierarchical Syntax Prefix Reference or Individual Field Reference

Method 1 - Hierarchical Syntax Prefix Reference

Be sure to use a prefix which will not be found as an individual field name or part of the text content of the file. In this example, “HSPR” is used. Example: HSPR.Text1 is a text box field name. The Dot is necessary within the field name to indicate the syntax parts keeping the prefix separate from the field name.

Note: in the following scripts, replace the field names with the names of the fields you are working with for the these field names:

“Yes_ckbx”; “No_ckbx”; “HSPR”; “SkipToFieldName”.

Yes Checkbox: The Action is the Mouse Up Event, Run a Java Script

if(event.target.isBoxChecked(0))

{

this.resetForm([“No_ckbx”]);

this.getField("HSPR").readonly = false;

}

No Checkbox: The Action is the Mouse Up Event, Run a Java Script

if(event.target.isBoxChecked(0))

{

this.resetForm([“Yes_ckbx”]);

this.getField("HSPR").readonly = true;

this.resetForm([“HSPR”]);

this.getField(“SkipToFieldName”).setFocus();

}


Method 2 Referencing Each Field Name

Note: in the following scripts, replace the field names with the names of the fields you are working with for the these field names:

“Yes_ckbx”; “No_ckbx”; “Text1”; “Text2”; “SkipToFieldName”.

Yes Checkbox: The Action is the Mouse Up Event, Run a Java Script

if(event.target.isBoxChecked(0))

{

this.resetForm([“No_ckbx”]);

this.getField("Text1").readonly = false;

this.getField("Text2").readonly = false;

}

No Checkbox: The Action is the Mouse Up Event, Run a Java Script

if(event.target.isBoxChecked(0))

{

this.resetForm([“Yes_ckbx”]);

this.getField("Text1").readonly = true;

this.getField("Text2").readonly = true;

this.resetForm([“Text1”,”Text2”]);

this.getField(“SkipToFieldName”).setFocus();

}

Resources

and

Lori Kassuba of Allta Media, LLC, How to exclude a form field from the tab order,

Recent Posts

See All
The PC Tech logo with cross, magnifying glass, and pc

What Resources do you need?

Delivering actionable communication solutions to achieve business goals

bottom of page