PDF Editing Issues

How to Set a Default Form Value Only When Another Field Is Filled in PDF

Muhammad TalhaMuhammad Talha Nov 5, 2026 869 views

Question details

The user wants to automatically populate a secondary form field (like a description) when a primary field (like a date) is filled, and keep it blank when the primary field is empty.

How to Auto-Fill a PDF Form Field Based on Another Field's Input
Product
WPS PDF
Device & OS
not provided
Scenario
Creating interactive PDF forms where conditional logic is needed to streamline user data entry.
Observed behavior
The user requires a method to dynamically update a secondary field's value based on whether the primary trigger field contains data.
Before you start

Ensure that your PDF editor supports JavaScript for form validation, and note down the exact case-sensitive names of the fields you want to link.

Solution 1Recommended

Use a Custom JavaScript Validation Script

Add a validation script to the primary trigger field so it automatically sets the value of the secondary field based on its own input status.

PDF forms support JavaScript to handle dynamic logic. By adding a simple validation script to your primary field, you can control the text that appears in a target field automatically.

1
Open Field Properties

Enter the form editing mode in your PDF application. Right-click the primary field (e.g., the Date field) that will trigger the change and select 'Properties'.

2
Access Custom JavaScript Settings

Navigate to the 'Validate' or 'Validation' tab in the Properties window, and select the option to run a custom JavaScript.

3
Insert the Script

Enter the following code: if (event.value == "") this.getField("Description").value = ""; else this.getField("Description").value = "Description goes here";

4
Customize Field Names

Replace 'Description' in the script with the exact name of your secondary target field, and change 'Description goes here' to the default text you want to populate.

5
Save and Test

Close the properties dialog, exit form editing mode, and test the form by entering a value into the primary field to see the secondary field populate.

Use a Custom JavaScript Validation Script
Manual Editing Still Allowed: Even after the secondary field is automatically populated by the script, a user can still manually edit the description if they need to add specific details.
Advanced PDF Forms

Create and Edit Interactive PDF Forms with WPS Office

WPS Office provides a comprehensive PDF editor to help you design interactive forms, manage field properties, and ensure seamless document data collection.

  1. 1. Open your PDF: Launch WPS Office and open the PDF document you want to edit.
  2. 2. Navigate to the Form Tab: Click on the 'Form' tab on the top ribbon to access the interactive form tools.
  3. 3. Insert and Edit Fields: Click to add new form fields or double-click existing ones to modify their properties and logic.
Easily insert interactive PDF form fields like text boxes, checkboxes, and dropdowns.Highly compatible with standard PDF formats and Adobe Acrobat forms.Lightweight software that runs smoothly on multiple platforms.
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my target PDF form field updating automatically?

Make sure you entered the exact field name in the JavaScript code, as field names are case-sensitive. Additionally, ensure your PDF viewer has JavaScript execution enabled.

Can I use this method to link a checkbox to a text field?

Yes, you can modify the JavaScript to check the state of a checkbox (e.g., checking if event.value is 'Yes' or 'Off') instead of checking if a text field is empty.

Will the auto-filled value overwrite the user's manual input?

The validation script triggers only when the primary field is modified. If a user manually edits the secondary auto-filled field afterwards, their changes will remain unless the primary field is altered again.