PDF Editing Issues

Set a Date Range Validation Rule for an Acrobat Form Field

Ayan MasoodAyan Masood Nov 25, 2026 868 views

Question details

The user wants to restrict an Acrobat form field to dates between a defined start date and end date.

Set a Date Range Validation Rule for an Acrobat Form Field
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form has a date field that should accept only dates within a specified range.
Observed behavior
The field should accept dates within the range and reject dates outside it.
Before you start

Open the PDF in Adobe Acrobat and identify the date field you want to restrict. Decide on the inclusive start and end dates and the date format users should enter.

Solution 1Recommended

Add a custom date validation script in Acrobat

Use a field validation script to check entered dates against inclusive start and end dates.

The example accepts dates from January 1 through December 31, 2025, in MM/DD/YYYY format. Change the two Date values and the error message to match your range.

1
Open the form field properties

In Acrobat, open the PDF and select All tools > Prepare a form. Double-click the date field to open its properties.

2
Set the date format

On the Format tab, choose Date and select the MM/DD/YYYY format.

3
Enter the validation script

On the Validate tab, select Run custom validation script and click Edit. Paste this script: if (event.value !== "") { var value = String(event.value); var entered = null; try { entered = util.scand("mm/dd/yyyy", value); } catch (e) { entered = null; } var minDate = new Date(2025, 0, 1); var maxDate = new Date(2025, 11, 31); if (!entered || util.printd("mm/dd/yyyy", entered) !== value || entered.getTime() < minDate.getTime() || entered.getTime() > maxDate.getTime()) { app.alert("Enter a date from 01/01/2025 through 12/31/2025."); event.rc = false; } }

4
Set your range

In the script editor, replace the minDate and maxDate values with your limits and update the alert text. JavaScript months run from 0 for January to 11 for December. Click OK and close the field properties.

5
Test and save the form

Use Preview in Prepare a form to enter dates at both limits and dates outside the range. Confirm that the limits are accepted and outside dates are rejected, then select File > Save.

Add a custom date validation script in Acrobat
Blank dates and PDF viewers: The script allows a blank field. To require an entry, select Required on the field's General tab. Test the completed form in the PDF viewer recipients will use, because JavaScript support varies.
Free Microsoft Office alternative

Work with PDF forms 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 helps you move existing files without starting over. The Acrobat JavaScript validation rule above should still be created and tested in Acrobat.

Open and work with PDF documents alongside your other filesCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar interface for a smoother transition from Microsoft OfficeFree, lightweight tools for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Are the start and end dates included in the allowed range?

Yes. The script rejects dates earlier than minDate or later than maxDate, so both boundary dates are accepted.

How do I change the permitted dates?

Open the field properties in Prepare a form, go to Validate, and edit the custom script. Change minDate, maxDate, and the alert message. Remember that JavaScript months are numbered 0 through 11.

How can I make the date field mandatory?

In Prepare a form, double-click the field and select Required on the General tab. The example validation script itself permits a blank value.

Will the validation work in every PDF viewer?

Not necessarily. Custom validation relies on Acrobat JavaScript support, which varies by viewer and its settings. Test the saved form in the viewer your recipients will use.