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

Adobe LiveCycle Data Field

Avatar

Level 1

Hello everyone,

 

I've created a date field and I need to validate the date so that it is after 01-01-2022.

 

If the user enters a date earlier than the date, it should give an appropriate message and the value of the date field should be null.

 

Please help.

 

Thanks

 

Aitor

1 Reply

Avatar

Community Advisor

Hi @Aitor_ ,

Try this, 

var entryDate = date2num($.formattedValue, "MM/DD/YYYY")
var currentDate = date()
if (entryDate lt date()) then
$host.messageBox("Date cannot be in the past", "Date in the past", 0, 0)
else if (entryDate gt currentDate) then
//do Something
endif

Hope that helps!

Regards,

Santosh

Avatar

Level 1

Hi @SantoshSai ,

 

I have tried to apply the code but How can I specify that it only correctly validate dates from 01-01-2022?

 

Thanks a lot,

 

Aitor