Other PDF Issues

Validate Numeric Input in an Adobe Acrobat app.response Dialog

Steven ParkerSteven Parker Nov 19, 2026 868 views

Question details

Validate a user's numeric entry in an Acrobat JavaScript app.response dialog before the script continues.

Validate Numeric Input in an Adobe Acrobat app.response Dialog
Product
Adobe Acrobat JavaScript
Device & OS
not provided
Scenario
A script asks users to enter a number through an app.response dialog.
Observed behavior
The dialog also allows users to enter letters or symbols.
Before you start

Locate the Acrobat JavaScript that calls app.response and check that Acrobat JavaScript is enabled. Decide whether the input should contain only digits or also allow decimals, signs, or separators.

Solution 1Recommended

Validate the app.response result before continuing the script

Use this approach when the existing dialog should accept only one or more digits.

The app.response dialog does not prevent users from typing nonnumeric characters. Test the returned value and keep code that depends on valid input inside the valid branch.

1
Open the script

In Acrobat, open the JavaScript editor for the script that contains your app.response call. For a document-level script, use All tools > Use JavaScript > Document JavaScripts; menu names may vary by version.

2
Check the response

After the dialog call, handle cancellation and test for digits. For example: var cRTN = app.response("Enter a whole number:"); if (cRTN === null) { // User canceled; do not continue. } else if (!/^\d+$/.test(cRTN)) { app.alert("Invalid value. Enter digits only."); } else { // Continue with code that uses cRTN. }

3
Test the dialog

Run the script and try a valid entry such as 123, an entry containing letters or symbols, an empty entry, and Cancel. Confirm that dependent code runs only for valid input.

Validate the app.response result before continuing the script
Allowed input: The expression accepts digits only, including leading zeros. It rejects spaces, negative signs, decimal points, and separators; change the validation if those are required.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility makes it easier to move existing files into a single workspace. It does not fix or replace Acrobat app.response JavaScript validation.

Open and work with PDF documents alongside Office files.Compatible with Microsoft Office formats such as DOCX, XLSX, and PPTX.Familiar editing interface for a smoother move from Microsoft Office.Free, lightweight suite for everyday document tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Can app.response block letters while the user types?

The standard app.response dialog does not provide a digits-only input restriction. Validate its returned value after the dialog closes and show an app.alert for invalid input.

What does app.response return when the user cancels?

It returns null. Check for null before applying the regular expression or using the response, and avoid running the dependent code when the user cancels.

Does the digits-only expression accept decimal numbers?

No. /^\d+$/ accepts one or more digits but rejects decimal points, signs, spaces, and separators. Use a different validation rule if your script needs those characters.

Can I use a Number-formatted field instead of a dialog?

Yes. In Acrobat, open Prepare a form, select a text field, and choose Number on its Properties > Format tab. This controls the form field rather than the app.response dialog.