PDF Editing Issues

Display CLEAR in a Numeric PDF Form Field

Emma BrownEmma Brown Nov 19, 2026 868 views

Question details

Display CLEAR when the absolute difference between two numeric PDF form fields reaches a specified threshold.

Display CLEAR in a Numeric PDF Form Field
Product
PDF form editor
Device & OS
not provided
Scenario
A calculated form field compares two numeric inputs, and a threshold field determines when a status should appear.
Observed behavior
The calculated field uses number formatting, which conflicts with displaying a text value such as CLEAR.
Before you start

Open the PDF in an editor that supports form-field calculations and JavaScript, such as Adobe Acrobat. Check the exact names of the two input fields, the threshold field, and the calculated field before adding scripts.

Solution 1Recommended

Add a separate text field for the CLEAR status

Keep the difference field numeric and use a separate field to display CLEAR when the threshold is reached.

A number-formatted field should contain a number or be blank. A separate status field avoids mixing text with the numeric result.

1
Open the form editor

In Adobe Acrobat, open the PDF and select All tools > Prepare a form. Verify that the input fields are named BOW MARK and OBJECT AHEAD and that the threshold field is named LOA, or adjust the names in the scripts below.

2
Calculate the numeric difference

Open the properties of the result field, name it Difference, and set Format to Number. Under Calculate, select Custom calculation script and click Edit. Enter: var a = this.getField("BOW MARK").value; var b = this.getField("OBJECT AHEAD").value; event.value = (a === "" || b === "" || isNaN(Number(a)) || isNaN(Number(b))) ? "" : Math.abs(Number(a) - Number(b));

3
Create the status field

Add a text field named Status. In its properties, set Format to None, then choose Calculate > Custom calculation script > Edit. Enter: var d = this.getField("Difference").value; var limit = this.getField("LOA").value; event.value = (d !== "" && limit !== "" && !isNaN(Number(d)) && !isNaN(Number(limit)) && Number(d) >= Number(limit)) ? "CLEAR" : "";

4
Set the calculation order and test

In Prepare a form, use More > Set Field Calculation Order and place Difference before Status. Save the PDF, then enter values in BOW MARK, OBJECT AHEAD, and LOA to test results below, equal to, and above the threshold.

Add a separate text field for the CLEAR status
Check PDF viewer support: The automatic status depends on the PDF viewer supporting and allowing form JavaScript. Test the saved form in the viewer your recipients will use.
Free Microsoft Office alternative

Work with PDF Forms and Office Files in WPS Office

WPS Office is a free, lightweight Microsoft Office alternative with a familiar interface for working with documents and PDFs. Open existing Office files for an easier move to WPS; use a PDF editor that supports form JavaScript for the automatic CLEAR calculation described above.

Open and fill supported PDF forms alongside your documents.Work with Microsoft Office formats including DOCX, XLSX, and PPTX.Use a familiar interface to ease migration from Microsoft Office.Access a free, lightweight office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Why can't the numeric field display CLEAR reliably?

Number formatting expects a numeric value or a blank. Put CLEAR in a separate text field, or change the result field's format to None and handle its display with a script.

Can I show either the number or CLEAR in one field?

Yes. In the field's Properties, set Format to None and use a custom calculation script to return CLEAR at the threshold or a formatted number otherwise. Acrobat JavaScript's util.printf can format the numeric result.

What happens when an input or threshold is blank?

The example scripts leave the difference or status blank until the required values are present. Enter zero explicitly if zero is the intended input or threshold.

Why does the status show the previous result?

Check the form calculation order in Acrobat's Prepare a form tool. Set Difference to calculate before Status, then save and test the form again.

Will the status work in every PDF viewer?

Not necessarily. The viewer must support and allow PDF form JavaScript. Test the form in the viewer recipients will use before relying on the automatic status.