PDF Editing Issues

Make an Acrobat Form Field Required Only When the Answer Is Yes

Khadija KhanKhadija Khan Nov 18, 2026 869 views

Question details

Make an Explanation field required when a user selects Yes and optional when the user selects No or makes no selection.

Make an Acrobat Form Field Required Only When the Answer Is Yes
Product
Adobe Acrobat PDF Forms
Device & OS
not provided
Scenario
A PDF form asks a Yes or No question and needs an explanation only for a Yes answer.
Observed behavior
The Explanation field should be marked as required only when the Yes option is selected.
Before you start

Open the form in Acrobat and check the Yes/No field name and the export value assigned to Yes. The example uses the field name 4YN and the Yes export value Y; replace them if your form uses different values.

Solution 1Recommended

Add a conditional calculation script to the Explanation field

Use Acrobat JavaScript to update the field's required status whenever the Yes/No answer changes.

1
Open the form editor

Open the PDF in Acrobat and select Prepare a form from the tools.

2
Check the answer field

Open the Yes/No field's properties and verify its field name and the export value for Yes. For radio buttons, use the group field name in the script.

3
Open the calculation script

Open the Explanation field's properties, select the Calculate tab, and choose Custom calculation script. Click Edit.

4
Enter the script

In the script editor, enter: event.target.required = this.getField("4YN").valueAsString == "Y"; Replace 4YN and Y with your field name and Yes export value if necessary, then confirm and close the properties.

5
Test both answers

Select Preview in Prepare a form, choose Yes, and check that Explanation is required. Then choose No or clear the selection and check that it is optional. Test the form's submit action if it has one.

Add a conditional calculation script to the Explanation field
Check viewer support: The PDF viewer must support Acrobat JavaScript and have it enabled. Required fields are typically checked during form submission, not simply when the PDF is saved.
Free Microsoft Office alternative

Work with PDFs and Office documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its Microsoft Office format support helps you move existing files into your workflow. Use Acrobat to configure and test the conditional JavaScript described above.

Open and work with PDF documents alongside Office filesCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for an easier transition from Microsoft OfficeFree, lightweight tools for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

What should I change if my Yes option does not use the value Y?

In Prepare a form, check the Yes option's export value in its properties. Replace "Y" in the script with that exact value, including its capitalization.

Does the script require an explanation if no answer is selected?

No. The comparison is true only when the answer field's value is Y, so Explanation is optional for No or no selection. To require an answer to the Yes/No question itself, set that field as required in its properties.

Where do I add the script?

In Acrobat, open Prepare a form, open the Explanation field's properties, and select Calculate > Custom calculation script > Edit.

Why does the required setting not change in another PDF viewer?

The viewer may not support Acrobat JavaScript or may have it disabled. Test the form in Acrobat or Acrobat Reader with JavaScript enabled, and use the form's submit action to check required-field validation.