PDF Editing Issues

Change PDF Form Text and Fill Colors Based on a Drop-Down Selection

Jason MillerJason Miller Nov 18, 2026 868 views

Question details

Change a PDF form field's text and fill colors according to a Pass or Fail drop-down selection.

Change PDF Form Text and Fill Colors Based on a Drop-Down Selection
Product
PDF forms
Device & OS
not provided
Scenario
A form designer wants a target field to display different colors when a user selects a result from a drop-down list.
Observed behavior
The desired result is white text on green for Pass, white text on red for Fail, and black text on white for other values.
Before you start

Open the form in a PDF editor that supports Acrobat-compatible form JavaScript, such as Adobe Acrobat Pro. Identify the drop-down field, the target field name, and the drop-down export values.

Solution 1Recommended

Use a Drop-Down Validation Script in Adobe Acrobat Pro

Run a script when the drop-down value is committed to update the target field's colors.

This example uses a drop-down with export values Pass and Fail and a separate target field named Result. Change the field name and values in the script if your form uses different ones.

1
Open the form editor

Open the PDF in Adobe Acrobat Pro and select Tools > Prepare a Form, or choose Prepare a form from the All tools menu.

2
Check the drop-down options

Double-click the drop-down field, open the Options tab, and check that the Pass and Fail options have matching export values. Enable Commit selected value immediately so the script runs when a selection is made.

3
Add the validation script

In the drop-down field properties, open the Validate tab, select Run custom validation script, and click Edit. Paste this script: var target = this.getField("Result"); if (target) { if (event.value === "Pass") { target.textColor = color.white; target.fillColor = color.green; } else if (event.value === "Fail") { target.textColor = color.white; target.fillColor = color.red; } else { target.textColor = color.black; target.fillColor = color.white; } }

4
Save and test the form

Click OK to close the script editor and field properties, save the PDF, and leave form editing mode. Select Pass, Fail, and another available value in the drop-down to check the target field colors.

Use a Drop-Down Validation Script in Adobe Acrobat Pro
PDF viewer support varies: The colors depend on the viewer running PDF form JavaScript. Test the saved form in the viewer your recipients will use; some browser and mobile PDF viewers may not run the script.
Free Microsoft Office alternative

Work with PDFs and Office Files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Microsoft Office files, making it easy to move between formats. For the conditional PDF form script above, use an editor and viewer that support Acrobat-compatible JavaScript.

Open and review PDFs alongside documents and spreadsheetsWork with Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface for a smoother move from Microsoft OfficeAccess core office tools in one lightweight application
microsoft office alternative - wps office

Frequently Asked Questions

Why don't the colors change when I select Pass or Fail?

In Prepare a Form, check the target field name and the drop-down option export values against the script. Also enable Commit selected value immediately on the drop-down's Options tab and test in a viewer that supports PDF form JavaScript.

Can the field show a default color for a blank selection?

Yes. The script's final else block sets black text and a white fill for any value other than Pass or Fail, including a blank value when that selection is committed.

Will the script work in every PDF viewer?

No. Some browser and mobile viewers do not support Acrobat-compatible form JavaScript. Open and test the saved PDF in the viewer intended for the form's users.

How do I use different field names or option values?

In the validation script, replace Result with the exact target field name and replace Pass and Fail with the corresponding drop-down export values. Check these in Prepare a Form field properties.