PDF Editing Issues

How to Create a Fillable PDF Field with Grayed-Out Placeholder Text

Phi Hung VoPhi Hung Vo Nov 3, 2026 869 views

Question details

The user wants to add a default placeholder text (like "Enter Text") to a PDF form field that appears gray and automatically turns black when the user enters their own information.

How to Create a Fillable PDF Field with Grayed-Out Placeholder Text
Product
PDF
Device & OS
not provided
Scenario
Designing an interactive PDF form where text fields need instructional placeholder text to guide users on what to input.
Observed behavior
The goal is to display a gray prompt by default, which is replaced by standard black text once the user interacts with the field and inputs data.
Before you start

Ensure you are using a professional PDF editor that supports form creation and executing custom JavaScript for document fields.

Solution 1Recommended

Use a Custom Format Script to Set Placeholder Text

You can achieve the placeholder effect by applying a custom JavaScript format to the specific text field's properties.

Since the standard PDF specification does not include a native HTML-like 'placeholder' attribute, using a custom JavaScript format script is the standard workaround. This script checks if the field is empty (or at its default value) and applies a gray color and default text.

1
Open form field properties

Open your PDF form in edit mode, right-click the target text field, and select 'Properties' from the context menu.

2
Navigate to the Format tab

In the Properties dialog box, go to the 'Format' tab and select 'Custom' from the Select format category dropdown list.

3
Enter the custom script

In the Custom Format Script box, enter the following code: if (event.value == event.target.defaultValue) { event.target.textColor = ["G", 0.5]; event.value = "Enter Text"; } else event.target.textColor = color.black;

4
Apply and test

Click 'OK' or 'Close' to save the properties. Preview your PDF form and test the field to ensure the gray 'Enter Text' prompt turns to black when you type.

Use a Custom Format Script to Set Placeholder Text
Customizing the text: You can replace 'Enter Text' in the script with any specific prompt your form requires, such as 'First Name' or 'MM/DD/YYYY'.
Advanced PDF Editing Simplified

Create and Manage PDF Forms with WPS PDF

WPS Office offers a comprehensive PDF editor that makes it incredibly easy to view, fill, and manage interactive PDF forms. Whether you are inputting data or managing document properties, WPS provides a smooth and efficient experience.

  1. 1. Open your PDF document: Launch WPS Office and open the PDF file you wish to edit or fill.
  2. 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to view all available form creation and editing tools.
  3. 3. Add a text field: Click on 'Text Field' and drag your cursor over the document to create a new input area.
  4. 4. Modify properties: Double-click the newly created text field to open its properties, where you can adjust appearance, default text, and formatting.
Easily insert, modify, and manage interactive form fieldsFully compatible with standard Adobe PDF forms and propertiesLightweight, fast, and features an intuitive user interfaceSeamlessly convert filled PDFs to Word, Excel, or image formats
microsoft office alternative - wps office

Frequently Asked Questions

Can I change the color of the placeholder text?

Yes. In the provided JavaScript, the array ["G", 0.5] represents a 50% gray color in the grayscale color space. You can adjust this value (e.g., ["G", 0.7] for lighter gray) or use RGB arrays like ["RGB", 1, 0, 0] for red.

Why doesn't the placeholder text clear immediately when I click the field?

The format script triggers based on the field's value evaluation, which usually happens when the field loses focus. To make it clear immediately upon clicking, you would need to add an additional custom 'On Focus' JavaScript.

Will this JavaScript work in all PDF readers?

The script will work perfectly in robust PDF applications like Adobe Acrobat and WPS Office that support JavaScript execution. However, some basic browser-based PDF viewers or mobile readers may lack full JavaScript support and display standard black text instead.

Is there a non-JavaScript way to add placeholder text?

Standard PDF specifications do not natively support HTML-style placeholders. Using a default value combined with a custom JavaScript formatting script remains the most reliable method to achieve this specific visual effect.