Copy link to clipboard
Copied
I am creating an acrobat form with a date field. How can I prevent the user from entering a date from any year prior to the current year?
For example it's 2024 now. If a user enters a date with 2023 for the year a message appears instructing them to use current year dates only.
Copy link to clipboard
Copied
As the custom Validation script of the field enter the following (adjust the date pattern as needed):
if (event.value) {
var d = util.scand("mm/dd/yyyy", event.value);
if (d.getFullYear()<new Date().getFullYear()) {
app.alert("You may not enter a date from previous years.",1);
event.rc = false;
}
}
Copy link to clipboard
Copied
Please note that you have defined a hard stop. On January first, they can't enter data from the prior year. Seems to be a bit to hard...
Copy link to clipboard
Copied
This script will not work in Acrobat Reader.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now