Skip to main content
Participant
May 7, 2024
Question

Acrobat Forms: Don't Allow Prior Year Date Entries

  • May 7, 2024
  • 3 replies
  • 443 views

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. 

This topic has been closed for replies.

3 replies

Bernd Alheit
Community Expert
Community Expert
May 8, 2024

This script will not work in Acrobat Reader.

Abambo
Community Expert
Community Expert
May 8, 2024

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...

ABAMBO | Hard- and Software Engineer | Photographer
try67
Community Expert
Community Expert
May 8, 2024

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;
	}
}