PDF Editing Issues

How to Replace Default Form Field Text When Typing in PDF

Muhammad TalhaMuhammad Talha Nov 5, 2026 869 views

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.

How to Auto-Clear Default Form Field Text When Users Start Typing in PDFs
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.
Before you start

Ensure you have a PDF editor that supports form creation and custom JavaScript actions, and open your fillable PDF document in editing mode.

Solution 1Recommended

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.

1
Open Form Field Properties

Right-click the specific text field in your PDF form and select 'Properties' from the context menu.

2
Add On Focus Script

Navigate to the 'Actions' tab. Choose 'On Focus' from the Select Trigger dropdown, and 'Run a JavaScript' from the Select Action dropdown. Click 'Add'.

3
Enter the Clear Text Code

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.

4
Add On Blur Script

Back in the Actions tab, choose 'On Blur' as the trigger and 'Run a JavaScript' as the action. Click 'Add'.

5
Enter the Restore Text Code

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.

Use Custom JavaScript for Form Field Focus and Blur Actions
Testing the Script: Make sure to exit Form Editing mode and use the standard Hand tool to click inside the field and verify that the text disappears and reappears correctly.
PDF Form Editing

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. 1. Open Your PDF: Launch WPS Office and open your PDF document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab located in the top ribbon menu to access the form editing tools.
  3. 3. Insert Form Fields: Click on 'Text Field' to draw a new input box, or select an existing one to modify it.
  4. 4. Edit Properties: Double-click the field to open its properties, where you can set default values, formatting, and interactive actions.
Create, edit, and fill interactive PDF forms effortlesslyFully compatible with standard PDF form fields and propertiesLightweight, fast, and user-friendly interface for all your office needs
microsoft office alternative - wps office

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.