PDF Editing Issues

How to Change PDF Form Placeholder Text Color and Size with JavaScript

Nimra MalikNimra Malik Nov 3, 2026 869 views

Question details

The user needs to customize the font color and size of instructional placeholder text inside PDF form fields using Acrobat JavaScript.

How to Change PDF Form Placeholder Text Color and Size with JavaScript
Product
PDF Form Editor
Device & OS
not provided
Scenario
Creating interactive PDF forms where temporary guidance text displays when a field is empty, but needs specific text formatting (size and color) to distinguish it from actual user input.
Observed behavior
The user applies JavaScript to set text size and color. While predefined colors and simple size scripts work fine on single-line text fields, applying custom RGB arrays or running these scripts on multiline text fields can lead to unexpected display behaviors, such as the text remaining gray instead of changing to black on focus.
Before you start

Ensure your PDF editor supports JavaScript for form fields, and that you have access to the field's Actions or Format properties to trigger On Focus and On Blur events.

Solution 1Recommended

Set Text Size and Use Predefined Colors

Use standard JavaScript properties to quickly assign a text size and apply a basic predefined color to your placeholder text.

Acrobat JavaScript provides straightforward properties to dynamically manipulate the appearance of form fields. You can easily adjust the font size and apply standard colors such as red, blue, or black.

1
Access the form field properties

Right-click the target text field in your PDF form editor, select 'Properties', and navigate to the 'Actions' or 'Calculate' tab to insert your custom JavaScript.

2
Set the text size

To define the font size, input the script: event.target.textSize = 10; (replace 10 with your desired font size).

3
Apply a predefined text color

To change the text color, use the script: event.target.textColor = color.red;. This method works exclusively with predefined color names recognized by Acrobat JavaScript.

Set Text Size and Use Predefined Colors
Script Trigger Options: For placeholder text, you typically place these scripts in the 'On Blur' event (when the user leaves an empty field) to show instructional formatting, and revert it in the 'On Focus' event (when the user starts typing).
Powerful PDF Form Editor

Create and Customize Interactive PDF Forms with WPS Office

WPS Office offers intuitive and comprehensive PDF editing capabilities. You can seamlessly add text fields, customize placeholder appearance, and design interactive PDF forms without relying on complex scripting.

  1. 1. Open your PDF: Launch WPS Office and open the PDF document you want to make interactive.
  2. 2. Access the Form tab: Navigate to the 'Form' tab on the top ribbon to access all interactive field tools.
  3. 3. Insert a Text Field: Click on 'Text Field' and drag to draw the input box on your document page.
  4. 4. Customize Field Properties: Double-click the newly created text field to open its Properties window. From here, you can directly set the font size, text color, and default value without writing JavaScript.
Easily insert and manage interactive PDF form fieldsCustomize font size, color, and field appearance with a visual interfaceHighly compatible with standard Adobe Acrobat PDF formsLightweight, fast, and user-friendly PDF document processing
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't my color change script work on multiline text fields?

Multiline fields in many PDF readers handle rich text formatting and focus events differently than standard single-line fields. Scripts executing On Focus and On Blur might fail to update the placeholder text color properly. Sticking to single-line fields is recommended if dynamic color swapping is critical for your form.

Can I use HEX color codes instead of RGB arrays for PDF JavaScript?

No, standard Acrobat JavaScript's textColor property does not natively accept web HEX codes (like #FF0000). You must convert your HEX colors to an RGB array format on a 0 to 1 scale, for example: ["RGB", 1, 0, 0].

How do I make the placeholder text disappear when the user clicks the field?

You need to add an 'On Focus' action to the field. The JavaScript should check if the current field value equals the placeholder text; if it does, the script sets the field value to empty ("") and changes the text color back to your normal input color (e.g., color.black).