PDF Editing Issues

How to Clear a Dependent PDF Field When the Source Field is Deleted

Jason MillerJason Miller Nov 3, 2026 869 views

Question details

The user needs a dependent calculated PDF form field to become blank automatically when the original source entry field is removed or cleared.

How to Clear a Dependent PDF Field When Another Field is Deleted
Product
PDF Form
Device & OS
not provided
Scenario
Creating interactive PDF forms with auto-populating fields, such as mileage or odometer tracking logs, where data from one row copies to the next.
Observed behavior
The target field correctly copies the initial value from the source field, but it retains the old data instead of turning blank when the source field's data is deleted.
Before you start

Ensure your PDF editing software supports JavaScript for forms and note down the exact names of the form fields you want to connect.

Solution 1Recommended

Use Conditional JavaScript in Field Validation

Apply a simple conditional assignment script to clear the dependent field when the source is empty.

By default, basic PDF calculation scripts might leave trailing data when source fields are cleared. Using a ternary operator ensures the target field dynamically updates to a blank state when the trigger field is empty.

1
Open Field Properties

Open your PDF form in edit mode and right-click the trigger field (e.g., 'Odometer EndRow2') to open its Properties.

2
Navigate to the Validate Tab

In the Properties window, click on the 'Validate' tab to set up a custom validation rule.

3
Enter Custom Script

Select 'Run custom validation script' and click 'Edit'. Enter the following script: getField("Odometer BeginRow2").value = event.value ? getField("Odometer EndRow1").value : "";

4
Adapt Field Names

Replace 'Odometer BeginRow2' and 'Odometer EndRow1' in the script with the exact names of your dependent and source fields.

5
Save and Test

Click 'OK', close the properties, and test the form by entering a value in the source field and then deleting it to ensure the dependent field clears.

Case-Sensitive Field Names: Make sure the field names in the JavaScript exactly match the names defined in your PDF form, as JavaScript is strictly case-sensitive.
Edit PDF Forms Easily

Create and Edit Advanced PDF Forms with WPS Office

WPS Office provides comprehensive PDF editing tools, allowing you to easily build interactive forms, add calculation scripts, and manage field properties without needing complex standalone software.

  1. 1. Open PDF Edit: Launch WPS Office and click on 'PDF Edit' to open your document.
  2. 2. Access Form Controls: Navigate to the 'Form' tab on the top ribbon to access interactive form controls.
  3. 3. Add Fields and Scripts: Add text fields, right-click them to enter 'Properties', and insert your custom JavaScript under the 'Calculate' or 'Validate' tabs.
  4. 4. Save Your Work: Save your interactive PDF to preserve the functional form scripts and share it with others.
Intuitive tools for interactive PDF form creation and fillingAllows custom JavaScript for automated calculations and validationsFully compatible with standard PDF formats (Adobe Acrobat)Lightweight, fast, and user-friendly interface
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't the PDF field clear automatically when I delete the source?

Standard PDF calculations often only trigger or overwrite when new valid data is entered. If you delete the data, the script may not pass a 'blank' value unless explicitly programmed to do so using conditional logic.

Can I use this script for other types of calculations?

Yes. The conditional statement format `event.value ? [Value if True] : [Value if False]` is a standard JavaScript logic gate that can be adapted for sums, differences, or text copying in any PDF form field.

Do I need to know programming to make PDF forms?

Basic forms do not require programming. However, for advanced dynamic behaviors like clearing dependent fields, applying custom validation, or complex math, basic JavaScript knowledge is highly beneficial.

Will these form scripts work if I open the PDF in a web browser?

It depends on the browser. While major desktop PDF readers and editors fully support JavaScript, built-in browser PDF viewers (like Chrome or Edge) often have limited support for advanced form scripts.