Skip to main content
Participant
September 11, 2023
Answered

Restrict the user from selecting a date less than two weeks from the current date.

  • September 11, 2023
  • 2 replies
  • 1198 views

I am wanting to restrict the user from selecting a date less than two weeks from the current date. Is this possible in Adobe acrobat's date field?

This topic has been closed for replies.
Correct answer Jessica259626836dsq

I managed to sort it using Googles AI 

if (event.value) {

var d = util.scand("dd/mm/yyyy", event.value);

var today = new Date();
var twoWeeksFromNow = new Date(today.getTime() + (14 * 24 * 60 * 60 * 1000));

if (d < today || d < twoWeeksFromNow) {
app.alert("Please select at least 2 weeks from today.");
event.rc = false;
}

}

2 replies

Jessica259626836dsqAuthorCorrect answer
Participant
September 12, 2023

I managed to sort it using Googles AI 

if (event.value) {

var d = util.scand("dd/mm/yyyy", event.value);

var today = new Date();
var twoWeeksFromNow = new Date(today.getTime() + (14 * 24 * 60 * 60 * 1000));

if (d < today || d < twoWeeksFromNow) {
app.alert("Please select at least 2 weeks from today.");
event.rc = false;
}

}

try67
Community Expert
Community Expert
September 12, 2023

This is not the best way of doing it, and it contains an unnecessary condition, but it should work, for the most part.

try67
Community Expert
Community Expert
September 11, 2023

Yes, using a custom-made Validation script, but keep in mind it won't prevent the calendar widget from showing these dates. It will just reject the user's selection when they make it.

Participant
September 12, 2023

Do you by any chance know the script? and can Acrobat also do a pop up to inform the user about what they can select?