top of page

Adobe Acrobat - Preventing Entry of Future Date

Updated: Nov 14, 2024

Issue

You may have a situation where you need to prevent entry of a Future date in a field. You need to watch out for the differences in how date and time are obtained by different date objects to prevent changes in dates from morning to afternoon.

Important: replace the names used for getField with the actual field names you have.

Format tab: use the date format: mm/dd/yyyy

Action tab: Trigger is On Blur and Action is Run JavaScript

Script:

if (event.value!="") {

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

if (d.getTime()>new Date().getTime()) {

app.alert("You may not enter a date in the future.");

getField("DOB1").value="";

getField("DOB1").setFocus();

event.rc = false;

}

}

Resource

The PC Tech logo with cross, magnifying glass, and pc

What Resources do you need?

Delivering actionable communication solutions to achieve business goals

bottom of page