PDF Editing Issues

How to Fix If-Then Comparison Scripts in Acrobat PDF Forms

John WilsonJohn Wilson Nov 3, 2026 869 views

Question details

The user needs to correct a JavaScript conditional statement in an Acrobat PDF form that evaluates incorrectly.

How to Fix If-Then Comparison Scripts in Acrobat PDF Forms
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating or editing an interactive PDF form with custom validation scripts.
Observed behavior
The form script always returns 'Valid' regardless of input because it uses an assignment operator (=) instead of a comparison operator (==).
Before you start

Before editing your form scripts, ensure you have a backup copy of your PDF file in case you need to revert any JavaScript changes.

Solution 1Recommended

Correct the JavaScript Equality Operator and Case Sensitivity

Replace the assignment operator with the equality operator and ensure standard JavaScript casing conventions are followed.

In JavaScript, a single equals sign (=) assigns a value, while a double equals sign (==) compares two values. Using a single equals sign in an 'if' statement will force the condition to evaluate as true, causing incorrect form validation.

Additionally, JavaScript is strictly case-sensitive. Built-in objects like 'event' must be written in lowercase to be recognized properly by the Acrobat JavaScript engine.

1
Open form editing mode

Open your PDF form in Adobe Acrobat and enter 'Prepare Form' mode from the tools menu.

2
Access field properties

Right-click the specific form field containing the validation script and select 'Properties'.

3
Edit the custom script

Navigate to the 'Calculate' or 'Validate' tab where your custom JavaScript is located and click 'Edit'.

4
Fix the comparison operator

Locate the conditional if statement. Change the single '=' to '==' to ensure the script compares the values rather than assigning them.

5
Correct case sensitivity

Check for case-sensitive syntax errors. Ensure 'Event.value' or any capitalized instances are corrected to the lowercase 'event.value'.

6
Save and test

Click 'OK' to save the updated script. Exit the form editing mode to preview and test the form fields, ensuring the validation now works correctly.

Correct the JavaScript Equality Operator and Case Sensitivity
Script Syntax: Correct syntax example: if (this.getField("Text11").value == this.getField("fill_9").value) { event.value = "Valid"; } else { event.value = "Error"; }
Free Microsoft Office alternative

Manage and Edit PDF Documents Easily with WPS Office

While complex custom JavaScript logic might require dedicated Adobe tools, you can handle everyday PDF reading, form filling, and document conversions quickly and seamlessly using WPS Office. It is a comprehensive, lightweight suite that serves as a perfect free alternative to traditional Office software.

  1. 1. Download the software: Visit the official WPS Office website and download the free installer for your operating system.
  2. 2. Open your documents: Launch WPS Office and easily open your existing PDFs, Word documents, Excel sheets, and PowerPoint files without losing formatting.
  3. 3. Edit and save: Use the built-in PDF tools to fill standard forms, annotate, or read documents, then save your changes securely.
Free, lightweight, and fast installation processFully compatible with Microsoft Office formats including Word, Excel, and PowerPointBuilt-in robust PDF editor for reading, filling, and annotating standard formsFamiliar, tabbed user interface for seamless and quick migration
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF form script always evaluate to true?

This usually happens when an assignment operator (=) is used instead of an equality operator (==) in the conditional statement. The single equals sign assigns the value and evaluates as true, bypassing the intended comparison.

Is JavaScript in Acrobat PDF forms case-sensitive?

Yes, JavaScript is strictly case-sensitive. Keywords, object names like 'event', and function calls must be written with the exact casing required by the language standards.

Can I edit PDF form scripts in free PDF readers?

No, standard free PDF readers only allow you to view documents and fill out basic forms. To add or edit custom JavaScript validation scripts, you need advanced PDF authoring software.

What is the difference between == and === in JavaScript?

The double equals (==) compares values for equality after performing type conversion if necessary. The triple equals (===) checks for strict equality, meaning it checks both the value and the data type without converting them.