PDF Editing Issues

How to Add and Validate a Six-Digit Field in an Acrobat Dynamic Stamp

Nimra MalikNimra Malik Nov 10, 2026 870 views

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.

How to Add and Validate a Six-Digit Field in an Acrobat Dynamic 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.
Before you start

Ensure you have Adobe Acrobat Pro installed, as creating and editing custom dynamic stamps with JavaScript requires advanced PDF form editing capabilities.

Solution 1Recommended

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.

1
Open the Stamp File

Open your custom dynamic stamp PDF file in Adobe Acrobat.

2
Access Field Properties

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.

3
Add Calculation Script

Go to the 'Calculate' tab, select 'Custom calculation script', and click the 'Edit' button.

4
Insert JavaScript Code

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 = "";

5
Save the Stamp

Click 'OK', close the properties dialog, and save the stamp PDF file.

Use JavaScript to Prompt and Validate Stamp Input
Editing Applied Stamps: Because the stamp is flattened upon placement, you cannot edit the 6-digit number later. If you make a mistake, you must delete the stamp from the document and apply it again.
Free Microsoft Office alternative

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. 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document.
  2. 2. Navigate to the Comment Tab: Click on the 'Comment' tab located on the top ribbon.
  3. 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. 4. Place the Stamp: Click anywhere on the document page to place your stamp.
Add, create, and manage custom stamps in PDFs effortlessly.Fully compatible with Microsoft Word, Excel, PowerPoint, and standard PDF formats.Lightweight and fast, ensuring smooth document processing.Free to use with a familiar, user-friendly interface.
microsoft office alternative - wps office

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.