PDF Editing Issues

How to Automatically Set Pass or Fail in a PDF Form

John WilsonJohn Wilson Oct 28, 2026 869 views

Question details

The user wants to automatically populate a pass or fail text field based on a numeric value entered in another PDF form field.

How to Automatically Set Pass or Fail in a PDF Form
Product
PDF Form Editor
Device & OS
not provided
Scenario
Creating an interactive PDF form that requires automated status grading (Pass/Fail) based on data input from users.
Observed behavior
A method or script is needed to automatically output 'P' or 'F' into a designated field when a specific numeric condition (min/max range) is met.
Before you start

Ensure you are using a PDF editor that supports JavaScript validation (like WPS Office or Adobe Acrobat) and that both the input field and the target result field have been created in your form.

Solution 1Recommended

Add a Custom Validation Script to Field Properties

Use a simple JavaScript validation script on the input field so it checks the entered numeric value and updates the target Pass/Fail field automatically upon commit.

The validation script is triggered when the value of a field is committed. This happens when the user presses Enter, presses Tab, or clicks outside the active field.

By adding a script to the input field's validation properties, it will compare the entered value against your defined minimum and maximum limits, and instantly push a 'Pass' or 'Fail' text string into your target field.

1
Open Input Field Properties

Enter the form editing mode in your PDF editor. Right-click the input field (e.g., named 'M1') where users will type the numeric value, and select 'Properties'.

2
Navigate to the Validation Tab

In the Properties dialog box, click on the 'Validate' tab. Select the option to 'Run custom validation script' and click 'Edit'.

3
Enter the JavaScript Code

Type the following script: this.getField("PF1").value = (event.value > Min && event.value < Max) ? "P" : "F";

4
Customize the Variables

Replace 'PF1' with the exact name of your target Pass/Fail text field. Replace 'Min' and 'Max' with your required numeric limits (for example, 50 and 100).

5
Test the Form

Save and close the properties. Exit form editing mode, type a number into the input field, and press Enter or Tab to see the 'PF1' field automatically update to 'P' or 'F'.

Add a Custom Validation Script to Field Properties
Field Naming Rule: Make sure your target field name inside the getField() brackets exactly matches the actual field name in your PDF, as JavaScript is case-sensitive.
Efficient PDF Form Editing

Create and Manage Interactive PDF Forms in WPS Office

WPS Office provides robust and user-friendly PDF editing tools, allowing you to create fillable forms, set advanced field properties, and manage interactive scripts effortlessly.

  1. 1. Open your PDF: Launch WPS Office and open your PDF document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access all interactive form creation features.
  3. 3. Edit Properties: Double-click any text field to open its properties menu and configure rules or validation settings.
Easily insert and customize interactive form fieldsHighly compatible with standard Adobe Acrobat PDF form formatsLightweight, fast, and features a familiar user interface
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my validation script updating the Pass/Fail field?

Ensure that the field name referenced in the script perfectly matches the name of your target field (case-sensitive). Additionally, confirm that JavaScript execution is enabled in your PDF reader's security settings.

When exactly does the validation script trigger?

The script runs automatically when the field value is committed. This occurs when the user presses the Enter key, presses the Tab key to move to the next field, or clicks anywhere outside the input field.

How should I set up the target Pass/Fail field?

Create a standard text field and give it a recognizable name (like 'PF1'). It is highly recommended to set this field's properties to 'Read-Only' so that users cannot manually override the automatically calculated Pass or Fail result.

Can I include 'equal to' in my minimum and maximum limits?

Yes. If you want the limit to be inclusive, change the strictly greater than (>) or less than (<) operators to greater than or equal to (>=) and less than or equal to (<=) in your JavaScript code.