How to Auto-Clear or Lock a Previous Address Field in PDF Forms
Question details
The user needs to automatically clear or lock the 'Previous Address' field in a PDF form if the applicant indicates they have lived at their current address for more than three years.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or configuring an interactive PDF application form with conditional logic.
- Observed behavior
- The user wants to implement an automated rule where the 'Previous Address' field is emptied or made read-only based on the numeric value entered in the 'Years at Current Address' field.
Ensure you have a PDF editor that supports JavaScript for interactive forms, and note the exact field names for both 'Years at Current Address' and 'Previous Address'.
Apply a Custom Validation Script Using JavaScript
Add a JavaScript snippet to the 'Years at Current Address' field to conditionally clear and lock the 'Previous Address' field.
You can use JavaScript to create dynamic interactions in PDF forms. By adding a validation script to the trigger field, the document automatically updates the target field when specific conditions are met.
Open the PDF form in Edit Mode and right-click the 'Years at Current Address' field, then select Properties.
Click on the 'Validate' or 'Calculate' tab within the field properties dialog box.
Select the option to 'Run custom validation script' and click the Edit button.
Enter a script similar to: if (event.value > 3) { this.getField('Previous Address').value = ''; this.getField('Previous Address').readonly = true; } else { this.getField('Previous Address').readonly = false; }
Save the properties, exit form editing mode, and test the form by entering a number greater than 3 in the 'Years at Current Address' field.

Create and Edit Dynamic PDF Forms with WPS Office
WPS Office provides powerful PDF editing tools that allow you to create interactive forms, add text fields, and manage document properties seamlessly.
- 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form tools.
- 3. Insert Form Fields: Click 'Text Field' to draw and insert boxes for your address data.
- 4. Configure Properties: Right-click the inserted fields to modify their properties, names, and visual appearances.

Frequently Asked Questions
Why isn't my JavaScript running in the PDF form?
Interactive scripts may be disabled in your PDF viewer's security settings. Ensure JavaScript execution is enabled in the preferences of the software you are using to view and fill out the form.
Can I hide the previous address field entirely instead of just locking it?
Yes. In your custom script, instead of setting the field to read-only, you can change its display property to hidden using: this.getField('Previous Address').display = display.hidden;
Does conditional logic in PDFs work on mobile devices?
Support for JavaScript in PDF forms varies widely by mobile app. While advanced desktop editors like WPS Office handle them perfectly, some basic mobile PDF viewers may not execute these scripts.




