Skip to main content
Participant
June 7, 2020
Question

Validating Start Date is within 90 Days from Today

  • June 7, 2020
  • 2 replies
  • 961 views

In a created form, I am trying to figure out how to use javascript to ensure that a selected date in a date field labeled "Start Date" is greater than 90 days from the current day/today. I would also like to implement alerts to convey a message to the user when the start date is greater than, less than, and equal to 90 days. I dont have any experience in javascript. Can anyone help with this?

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
June 7, 2020

Dates are more complicated than regular calculations because Dates are more complex. 

You can read about scripting for Date Handling here:

https://acrobatusers.com/tutorials/date_time_part1/

https://acrobatusers.com/tutorials/date_time_part2/

 

There are two important bits for such a script

1) Parsing the entered date text into a Date object

2) Adding 90 days to the current date so the date objects can be compared.

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
June 7, 2020

What should happen if it's not? Should the value be rejected, or just show an error message?

What is the date format of that field?

Participating Frequently
July 25, 2022

Hello, recognized your name from my other post 🙂 I'm also trying to figure out the above. If the date entered is greater than 90 days, I need an error message to display. Format is m/dd/yyyy. Any help is super appreciated. Thanks.