PDF Editing Issues

Change PDF Form Text Color When a Value Is Below 5 in Adobe Acrobat

Ayan MasoodAyan Masood Nov 25, 2026 870 views

Question details

Change a PDF form field's text color to red when its numeric value is below 5, including when the value is zero.

Change PDF Form Text Color for Values Below 5 in Adobe Acrobat
Product
PDF form editor with JavaScript support, such as Adobe Acrobat Pro
Device & OS
not provided
Scenario
A PDF form needs conditional text coloring based on a numeric field value.
Observed behavior
A truth test can skip zero because JavaScript treats it as false, preventing the value from being colored red.
Before you start

Open the PDF in an editor that supports form field JavaScript, such as Adobe Acrobat Pro, and identify the numeric field to validate. This example applies the color to the field being edited.

Solution 1Recommended

Use a validation script to color the numeric field

Apply this script to the numeric field so values below 5, including zero, display in red.

1
Open the form editor

In Adobe Acrobat Pro, open the PDF and select All tools > Prepare a form.

2
Open field properties

Double-click the numeric field, such as Quantity, and select the Validate tab in its properties.

3
Add the validation script

Select Run custom validation script, click Edit, and enter: var A = Number(event.value); if (A < 5) event.target.textColor = color.red; else event.target.textColor = color.black;

4
Save and test

Click OK to close the script editor and field properties, save the PDF, and test the field with 0, 4, and 5. Values 0 and 4 should be red; 5 should be black.

Use a validation script to color the numeric field
Blank values and viewer support: Number('') is 0, so an empty field may also turn red. The script requires a PDF viewer that supports Acrobat form JavaScript.
Edit PDF text in WPS Office

Manually Highlight Low Values in WPS PDF

For a static PDF, use WPS PDF's text editing tools to manually color values below 5 red. This is a manual workaround and does not automatically change an interactive form field's color when its value changes.

  1. 1. Open the PDF: Open WPS Office, choose Open, and select the PDF containing the value.
  2. 2. Select the text: Choose Edit PDF and select the text containing a value below 5.
  3. 3. Change the color: Use the text color control in the editing toolbar to choose red, then save the PDF.
Manually make low values stand out in redEdit PDF text in a familiar office-style interfaceWork with Microsoft Office formats including DOCX, XLSX, and PPTX
microsoft office alternative - wps office

Frequently Asked Questions

Why does zero not turn red in my PDF form?

A condition such as if (A) treats 0 as false. Compare the numeric value directly with 5 instead, using if (A < 5).

Where do I add the validation script in Acrobat?

Open All tools > Prepare a form, double-click the field, and go to Validate > Run custom validation script > Edit.

Why does an empty field turn red?

JavaScript converts an empty string to 0 when using Number(''), and 0 is below 5. Add an explicit blank-value check before the numeric comparison if blanks should stay black.

Will the color change work in every PDF viewer?

No. The automatic color change depends on the viewer supporting Acrobat form JavaScript. Test the saved PDF in the viewer your recipients will use.