How to Fix Acrobat PDF Form Field Text and Fill Color JavaScript Errors
Question details
The user needs to change the text and fill colors of a PDF form field dynamically using a JavaScript button script, but the colors fail to update.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Writing and executing document-level or field-level JavaScript to dynamically alter the appearance of PDF form fields.
- Observed behavior
- The script successfully updates the form field value, but the text color and fill color remain unchanged due to incorrect property casing. Additionally, field highlighting may be masking the actual fill color.
Before modifying your PDF JavaScript code, verify that the target form field is not set to read-only and that your PDF viewer has JavaScript execution enabled in its security settings.
Correct JavaScript Property Capitalization and Disable Highlighting
Adobe Acrobat's JavaScript API is strictly case-sensitive. You must use the exact camelCase properties for text and fill colors, and ensure runtime highlighting isn't hiding your changes.
A common mistake when scripting PDF forms is using completely lowercase property names. The properties for changing colors are camelCased.
Furthermore, many PDF viewers apply a default colored highlight to all form fields so users can easily see where to type. This highlight layer sits above your custom fill color, effectively masking it from view.
Right-click your button field in Form Edit mode, select 'Properties', navigate to the 'Actions' tab, and edit your 'Run a JavaScript' action.
Locate the line setting the text color and change 'textcolor' to the camelCase 'textColor'. For example: result.textColor = color.red;
Locate the line setting the background color and change 'fillcolor' to 'fillColor'. For example: result.fillColor = color.blue;
To ensure the viewer's default field highlighting isn't masking your new fill color, add this line to your script for testing: app.runtimeHighlight = false;

Edit PDF Form Fields Easily in WPS Office
Avoid complex JavaScript debugging by modifying PDF form field properties, text colors, and fill colors directly through WPS Office's intuitive PDF editing interface.
- 1. Open PDF in WPS Office: Launch WPS Office and open your interactive PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab in the top ribbon menu to access the form editing features.
- 3. Open Field Properties: Right-click the specific form field you want to modify and select 'Properties' from the context menu.
- 4. Adjust Colors: Go to the 'Appearance' tab to select your desired Text Color and Fill Color, click 'Close', and save the document.

Frequently Asked Questions
Why isn't my PDF form field fill color showing up after the script runs?
If your PDF viewer has form field highlighting turned on, it typically overlays a default color (like light blue) over all fields, which masks your custom fill color. Disable highlighting in your viewer's settings or use 'app.runtimeHighlight = false' in your script.
Is JavaScript required to change PDF form field colors?
No, you can set static text and fill colors directly in the form field properties using a PDF editor like WPS Office or Adobe Acrobat. JavaScript is only needed if you want the colors to change dynamically based on user interactions or specific conditions.
What happens if a PDF form field is set to read-only?
If a field is read-only, users cannot manually enter or alter data through the UI. However, its value and appearance can still be modified programmatically via JavaScript depending on the viewer's internal security and scripting permissions.




