Other PDF Issues

Toggle an Adobe Acrobat Form Field Between Required and Optional

Steve KSteve K Nov 19, 2026 869 views

Question details

Make a PDF comment field required when Yes is selected and optional when No is selected.

Toggle an Adobe Acrobat Form Field Between Required and Optional
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form uses a checkbox selection to control whether a user must enter a comment.
Observed behavior
The comment field becomes required when Yes is selected but remains required after the user selects No.
Before you start

Open the PDF in Acrobat and identify the exact name and export value of the Yes checkbox in Prepare Form. Check for existing scripts that also set the comment field's required property, as they may conflict with the calculation.

Solution 1Recommended

Recalculate the comment field's required state

Use a custom calculation script to set the comment field as required when the Yes checkbox has the specified export value and optional otherwise.

1
Open the form editor

Open the PDF in Adobe Acrobat and select Prepare Form from the tools.

2
Check the checkbox properties

Open the Yes checkbox's Properties and check its field name on the General tab and its export value on the Options tab.

3
Edit the comment calculation

Open the comment field's Properties, select the Calculate tab, choose Custom calculation script, and click Edit.

4
Set the required state

Enter event.target.required = this.getField("Yes1").valueAsString == "Yes_3"; and replace Yes1 and Yes_3 with the checkbox's actual field name and export value. Save the script and close Properties.

5
Test both selections

Close form editing, select Yes, and check that the comment field is required. Then select No and verify that the comment field is optional. Save the PDF after testing.

Recalculate the comment field's required state
Check viewer support: The calculation depends on Acrobat form JavaScript. Other PDF viewers may not run the script or enforce the required state in the same way.
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Office files. Its format compatibility can make moving everyday documents to WPS easier, but it does not fix Acrobat form JavaScript.

Open and review PDF forms alongside other documentsCompatible with Microsoft Office formats such as DOCX and XLSXUse a familiar interface for everyday document workMove existing Office files into a lightweight, free suite
microsoft office alternative - wps office

Frequently Asked Questions

Where do I find the checkbox's export value?

In Acrobat, open Prepare Form, open the checkbox's Properties, and select the Options tab. Use the listed export value in the calculation script.

Why does the comment field remain required after I select No?

The existing script may set the field to required without setting it back to optional. A custom calculation on the comment field assigns the required property based on the checkbox's current value.

What should I change in the example script?

Replace Yes1 with the exact checkbox field name and Yes_3 with its export value. You can check both in the checkbox's Properties in Prepare Form.

Will this script work in every PDF viewer?

Not necessarily. The solution relies on Acrobat form JavaScript, which other PDF viewers may not support. Test the form in the viewer your users will use.