PDF Editing Issues

Let Users Change Font Color in an Acrobat PDF Form

Anum MushtaqAnum Mushtaq Nov 24, 2026 868 views

Question details

Allow form users to change a field's font color while avoiding script conflicts and missing rich-text span errors.

Let Users Change Font Color in an Acrobat PDF Form
Product
Adobe Acrobat PDF forms
Device & OS
not provided
Scenario
A PDF form author wants users to choose rich-text colors in a field that also uses calculation or formatting logic.
Observed behavior
A calculation or format script can override the user's color choice, and accessing spans[0] can cause a TypeError when no rich-text span exists.
Before you start

Open the PDF in Acrobat and select Prepare a Form so you can inspect the affected text field and its scripts. Check whether the field is intended to accept numeric values and whether it already has calculation, validation, or format logic.

Solution 1Recommended

Enable rich text and apply the default color during validation

Use field validation to set a value-based color, then let users apply a different color with the Properties Bar.

A validation script can set the field's default color without assuming a rich-text span exists. Validation may run again after the field value changes and reset a user's color choice.

1
Enable rich-text formatting

In Acrobat, open Tools > Prepare a Form, double-click the affected text field, and select Allow Rich Text Formatting on the Options tab.

2
Review the format script

In the field's Properties dialog, open the Format tab and inspect any custom format script. Move the relevant color-setting logic to validation, and remove the separate custom format script if it is no longer needed.

3
Add validation logic

Open the Validate tab, select Run custom validation script, and click Edit. For a numeric field, enter: if (event.value == "" || Number(event.value) > 450) { event.target.textColor = color.black; } else { event.target.textColor = color.red; }

4
Test a user-selected color

Close the field Properties dialog, exit form editing, and enter a value. Select the field text and press Ctrl+E to open the Properties Bar, then choose a text color. Edit the value again to check whether validation resets the color.

Enable rich text and apply the default color during validation
Check other scripts: A calculation or validation script that sets textColor can still overwrite a user's choice when it runs. If other logic depends on spans[0], check that the rich-text span array exists and contains an item before accessing it.
Free Microsoft Office alternative

Edit PDF and Office documents with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. It can make migration easier through common format support, but it does not fix Acrobat form scripts or guarantee equivalent rich-text form behavior.

Open and work with PDF documents in WPS OfficeCompatible with Microsoft Office formats, including DOCX and XLSXUse a familiar interface for everyday document editingMove between PDF and Office files in one lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

Where do I enable rich text for an Acrobat form field?

Open Tools > Prepare a Form, double-click the text field, and select Allow Rich Text Formatting on the Options tab.

How can a form user change the text color?

After rich-text formatting is enabled, select text in the field and press Ctrl+E to open the Properties Bar, then choose a color.

Why does the font color change back after I edit the value?

A validation, calculation, or format script may set the field's textColor again. Inspect the field's Validate, Calculate, and Format tabs in Prepare a Form.

What causes a TypeError involving spans[0]?

The script may be accessing the first rich-text span when the span array is absent or empty. Check that the array exists and has at least one item before using spans[0].