Validate Numeric Input in an Adobe Acrobat app.response Dialog
Question details
Validate a user's numeric entry in an Acrobat JavaScript app.response dialog before the script continues.

- 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.
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.
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.
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.
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. }
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.

Use a Number-formatted PDF form field
Use a form field instead of an app.response dialog when users can enter the value directly in the PDF.
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.

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.




