Show and Require a PDF Field Based on a Yes or No Choice in Adobe Acrobat
Question details
Make a PDF form field visible and required when No is selected, and hidden and optional when Yes is selected.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form has Yes and No radio buttons that control whether another field needs to be completed.
- Observed behavior
- The dependent field should change its visibility and required status according to the selected radio button.
Open the form in a desktop version of Adobe Acrobat that supports Prepare a Form and JavaScript actions. Note the exact name of the field you want to control and confirm that the Yes and No choices are radio buttons.
Add JavaScript actions to the Yes and No radio buttons
Use separate Mouse Up actions to change the dependent field whenever the user selects a radio button.
Open the PDF in Acrobat and choose Tools > Prepare a Form. Find the dependent field and check its exact name in its properties.
Open the Yes radio button's Properties and select the Actions tab. Set Select Trigger to Mouse Up and Select Action to Run a JavaScript, then click Add. Enter: this.getField("field").display = display.hidden; this.getField("field").required = false;
Open the No radio button's Properties and, on the Actions tab, add a Run a JavaScript action for Mouse Up. Enter: this.getField("field").display = display.visible; this.getField("field").required = true;
In both scripts, replace field inside the quotation marks with the dependent field's exact name. Save the PDF, exit form editing, and select each radio button to test visibility. If the form has a Submit button, test that it checks the required field when No is selected.

Work with PDFs and Office Documents in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface and support for common Office formats, making it easy to move between documents. For the conditional PDF JavaScript in this article, use Adobe Acrobat to configure and test the form.

Frequently Asked Questions
Where do I find the dependent field's name?
In Acrobat, open Tools > Prepare a Form, select the field, and open its Properties. Use the exact field name in place of field in both scripts.
Why does the field stay visible when I select Yes?
Check the Yes button's Properties > Actions tab for a Mouse Up action set to Run a JavaScript. Confirm that the field name matches and that the PDF viewer supports Acrobat JavaScript.
Does marking a field as required prevent me from saving the PDF?
Not necessarily. The required setting is generally checked during form submission, so test it using the form's Submit button if one is present.
Will the field update automatically when the PDF opens?
The Mouse Up actions run when a user clicks a radio button. A form with an existing selection may need separate initialization on opening to synchronize the dependent field.




