Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

How can I prevent the entry of a future date in my date field?


Not applicable

I have a date field in my form (created w/ Adobe Lifecycle Designer v8.0) and I need to prevent users from entering a future date (current or past date is okay). Ideally, if a future date is entered, an error message pops up and tells the person that a future date is not acceptable. Does anyone know how to do this or have any suggestions to try?


2 Replies


Level 5
Hope the following JS code helps you..........

var checkDate = isCurrOrPastDate(this.rawValue)

if (checkDate == true) {

//"This date is valid current or past date.");

}else {"Date can not be a future date");; //set focus back to the data field.


function isCurrOrPastDate(dateStr) {

var dto = dateStr;

var iLen1 = String(dto).length;

var DD = dto.substring(iLen1, iLen1 - 2);

DD = DD.replace(/^\s*|\s*$/g,"");


var MM = dto.substring(5,7)

var YYYY = dto.substring(0,4);

//""+DD+" "+MM+" "+YYYY);

//return false;

var date1 = new Date(MM+"/"+DD+"/"+YYYY);//new Date(month+"/"+day+"/"+year);


var today = new Date();

var ddf = dateDifference(today,date1);

//"ddf: "+ddf);

if (ddf <= 0) {

//"This date is valid current or past date.");

return true; // date is valid


//"Date can not be a future date");

return false; // date is not valid


function dateDifference(strDate1,strDate2){

datDate1= Date.parse(strDate1);

datDate2= Date.parse(strDate2);


return (datDate2-datDate1)/(24*60*60*1000);



Level 2

hi Annie,

place the below code in the exit event of the date field and script language should be FormCalc


($.rawValue <> null )



num = IsoDate2Num($.rawValue)-Date()


( num > 0 )


$host.messageBox("Invalid Date and cannot be Future Date")


= ""

$host.setFocus("your field path")



Note : your field path for example your date field name is futuredate under subform name body then place body.futuredate.

if you want to resrict not to enter past date then compare num with < 0 or to current date then compare num with = 0.