PDF Editing Issues

How to Clear Default PDF Form Field Values on First Click

Natalie TaylorNatalie Taylor Nov 3, 2026 870 views

Question details

The user needs a script to clear a default placeholder value (e.g., "none") in a PDF form field only the first time it is clicked, ensuring subsequent user input is not deleted.

How to Clear Default PDF Form Field Values on First Click
Product
PDF Editor
Device & OS
not provided
Scenario
Creating interactive PDF forms where text fields have default placeholder text that needs to vanish when the user clicks to type.
Observed behavior
The original script clears the field on every click due to syntax errors, specifically an invalid semicolon after the if statement and unnecessary else logic, which erases user-entered text.
Before you start

Ensure you have access to a PDF editor that supports JavaScript form actions and that your document is currently in form editing mode.

Solution 1Recommended

Apply Correct JavaScript to a Mouse Action

Use a corrected JavaScript snippet on a mouse-up or mouse-down action to clear the default value without affecting user input.

When a script contains an invalid semicolon right after an 'if' statement, the condition is bypassed, causing the clearing action to execute every time the field is clicked. By correcting the syntax and removing unnecessary 'else' logic, the script will only clear the field if it contains the exact default value.

1
Open Form Field Properties

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

2
Navigate to the Actions Tab

Go to the 'Actions' tab, choose 'Mouse Up' (or 'Mouse Down') as the trigger, and select 'Run a JavaScript' as the action type.

3
Enter the Correct Script

Add the following exact script: if (event.target.value == "none") { event.target.value = ""; } (Replace "none" with your actual default placeholder text).

4
Save and Test

Click 'OK' to save the script, close the properties dialog, and exit form editing mode to test the field. The default text should now clear on the first click but retain your custom input afterward.

Apply Correct JavaScript to a Mouse Action
Preserve User Data: This targeted script precisely checks for the default text. If the user types anything else, the condition fails, and their input remains completely safe from being cleared.
PDF Form Solutions

Create and Manage Interactive PDF Forms with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to easily create interactive forms, edit text fields, and manage document properties efficiently for a smooth user experience.

  1. 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document to begin editing.
  2. 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to access all interactive field creation tools.
  3. 3. Add or Edit Text Fields: Click 'Text Field' to insert a new box or double-click an existing field to modify its properties and default text.
  4. 4. Save the Document: Once your form fields are configured, click 'Save' to ensure all interactive elements function correctly for your end users.
Easily create, fill, and edit interactive PDF forms.Highly compatible with Adobe Acrobat PDF formats and interactive forms.Lightweight application with a familiar, user-friendly interface.Seamlessly add text fields, checkboxes, and drop-down menus.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF form field clear every time I click it?

This usually happens due to a syntax error in your JavaScript, such as a misplaced semicolon right after an 'if' condition. This forces the clearing script to run regardless of the field's current value. Removing the semicolon and using the exact condition checking the target value fixes the issue.

Can I use 'Mouse Down' instead of 'Mouse Up' for this script?

Yes, both triggers work for this script. However, 'Mouse Up' is generally recommended for user interfaces because it allows the user to cancel the action by moving their cursor away before releasing the mouse button.

How do I set a default value for a PDF text field initially?

In form editing mode, open the field's Properties dialog, go to the 'Options' tab, and enter your desired placeholder text (like 'none' or 'Enter text here') in the 'Default Value' text box.