Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
3

Acrobat Forms: Don't Allow Prior Year Date Entries

New Here ,
May 07, 2024 May 07, 2024

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. 

TOPICS
PDF forms
433
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2024 May 08, 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;
	}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2024 May 08, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2024 May 08, 2024
LATEST

This script will not work in Acrobat Reader.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines