How to Add and Validate a Six-Digit Field in an Acrobat Dynamic Stamp
Question details
The user wants to create an Acrobat dynamic stamp that prompts for a reference number and validates that the input is exactly six digits before applying the stamp.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating a custom dynamic stamp that requires validated user input (a 6-digit number) upon placement.
- Observed behavior
- The user needs a script to prompt for input and validate it, as stamp fields are flattened and cannot be edited after placement.
Ensure you have Adobe Acrobat Pro installed, as creating and editing custom dynamic stamps with JavaScript requires advanced PDF form editing capabilities.
Use JavaScript to Prompt and Validate Stamp Input
Add a custom calculation script to your dynamic stamp's text field to prompt the user for a 6-digit number and validate it using regular expressions.
Dynamic stamp fields are flattened once applied to a document, meaning they cannot be edited afterward. To capture user input, you must prompt the user during the stamping process using the app.response() method.
By combining this prompt with a regular expression (/^\d{6}$/), you can ensure the user enters exactly six digits before the stamp is successfully placed.
Open your custom dynamic stamp PDF file in Adobe Acrobat.
Enter 'Prepare Form' mode and double-click the text field (e.g., 'Text2') where the 6-digit number should appear to open the Text Field Properties dialog box.
Go to the 'Calculate' tab, select 'Custom calculation script', and click the 'Edit' button.
Paste the following code into the editor: var answer = ""; while (!/^\d{6}$/.test(answer) && answer != null) { var answer = app.response({ cQuestion: "Enter a 6-digit number.", cTitle: "Reference", cLabel: "MAXIMO #" }); } if (answer != null) event.value = answer; else event.value = "";
Click 'OK', close the properties dialog, and save the stamp PDF file.

Edit and Manage PDFs Easily with WPS Office
While advanced JavaScript dynamic stamps are specific to Adobe Acrobat, WPS Office provides a comprehensive, lightweight, and free alternative for your everyday PDF editing, stamping, and document management needs. It is fully compatible with Microsoft Office formats and standard PDF files.
- 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document.
- 2. Navigate to the Comment Tab: Click on the 'Comment' tab located on the top ribbon.
- 3. Select or Create a Stamp: Click on 'Stamp' and choose from pre-defined stamps, or click 'Click to Add' to create a custom image stamp.
- 4. Place the Stamp: Click anywhere on the document page to place your stamp.

Frequently Asked Questions
Can I edit the 6-digit number after the dynamic stamp is placed?
No. Once a dynamic stamp is applied to a PDF, its form fields are flattened and become a permanent part of the document content. To change the number, you must delete the existing stamp and apply a new one.
What happens if the user enters letters instead of numbers in the stamp prompt?
The provided JavaScript uses a regular expression (/^\d{6}$/) to validate the input. If the user enters letters or an incorrect number of digits, the script will reject the input and prompt the user again until a valid 6-digit number is entered or the prompt is canceled.
Why is my custom calculation script not running when I place the stamp?
Ensure that the script is placed in the 'Calculate' tab of the specific text field within the stamp's source PDF file, not in the document-level JavaScript. Also, verify that JavaScript is enabled in your Acrobat preferences.




