How to Change PDF Form Placeholder Text Color and Size with JavaScript
Question details
The user needs to customize the font color and size of instructional placeholder text inside PDF form fields using Acrobat 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.
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.
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.
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.
To define the font size, input the script: event.target.textSize = 10; (replace 10 with your desired font size).
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.

Apply Custom RGB Colors to Placeholder Text
If standard predefined colors do not match your document's design, use an RGB array format to specify an exact custom color.
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. Open your PDF: Launch WPS Office and open the PDF document you want to make interactive.
- 2. Access the Form tab: Navigate to the 'Form' tab on the top ribbon to access all interactive field tools.
- 3. Insert a Text Field: Click on 'Text Field' and drag to draw the input box on your document page.
- 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.

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




