How to Replace Default Form Field Text When Typing in PDF
Question details
Configure a PDF form field so that the default placeholder text automatically disappears when a user clicks into the field to start typing.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Creating or editing a fillable PDF form that requires helpful placeholder text to guide users without forcing them to manually delete the default text.
- Observed behavior
- By default, text set as the 'Default Value' stays in the field and the user must manually highlight and delete it before typing.
Ensure you have a PDF editor that supports form creation and custom JavaScript actions, and open your fillable PDF document in editing mode.
Use Custom JavaScript for Form Field Focus and Blur Actions
Apply a simple script to the form field's properties that clears the default text when the field is clicked (On Focus) and restores it if left empty (On Blur).
To make placeholder text truly dynamic in a standard PDF, you need to use the field's action triggers. The 'On Focus' event occurs when the user clicks into the field, and the 'On Blur' event occurs when the user clicks away.
Right-click the specific text field in your PDF form and select 'Properties' from the context menu.
Navigate to the 'Actions' tab. Choose 'On Focus' from the Select Trigger dropdown, and 'Run a JavaScript' from the Select Action dropdown. Click 'Add'.
In the JavaScript editor, enter the following code replacing 'Your Text' with your exact placeholder: if(event.target.value=="Your Text"){event.target.value="";} Click OK.
Back in the Actions tab, choose 'On Blur' as the trigger and 'Run a JavaScript' as the action. Click 'Add'.
In the editor, enter this code to restore the text if the user leaves it empty: if(event.target.value==""){event.target.value="Your Text";} Click OK, then close the properties window and save your PDF.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides comprehensive PDF tools allowing you to create fillable forms, manage text fields, and streamline your document workflows with ease.
- 1. Open Your PDF: Launch WPS Office and open your PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab located in the top ribbon menu to access the form editing tools.
- 3. Insert Form Fields: Click on 'Text Field' to draw a new input box, or select an existing one to modify it.
- 4. Edit Properties: Double-click the field to open its properties, where you can set default values, formatting, and interactive actions.

Frequently Asked Questions
Can I set a default value without using JavaScript?
Yes, you can set a default value in the Options tab of the text field properties. However, this text acts as actual inputted data; it will not automatically disappear when the user clicks the field, requiring them to manually delete it.
Why does my placeholder text print when the field is empty?
If the placeholder text is technically set as the field's current value (which the JavaScript method does), it will appear on the printed document if left unchanged. To avoid this, you can set the form field's visibility properties to 'Visible but doesn't print', though this hides user input on printing as well. Alternatively, you can use a document-level print script to clear placeholders before printing.
Will this JavaScript method work on mobile PDF readers?
Most standard desktop PDF editors and viewers fully support JavaScript form actions. However, some basic browser-based PDF viewers or mobile PDF apps may have limited JavaScript support and might not execute the 'On Focus' and 'On Blur' scripts correctly.




