Let Users Change Font Color in an Acrobat PDF Form
Question details
Allow form users to change a field's font color while avoiding script conflicts and missing rich-text span errors.

- 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.
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.
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.
In Acrobat, open Tools > Prepare a Form, double-click the affected text field, and select Allow Rich Text Formatting on the Options tab.
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.
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; }
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.

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.

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].




