Set a Date Range Validation Rule for an Acrobat Form Field
Question details
The user wants to restrict an Acrobat form field to dates between a defined start date and end date.

- 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.
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.
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.
In Acrobat, open the PDF and select All tools > Prepare a form. Double-click the date field to open its properties.
On the Format tab, choose Date and select the MM/DD/YYYY format.
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; } }
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.
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.

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.

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.




