Discussion
5
Replies
17394
Views
CapitalOne
Posted: February 8, 2016
Last activity: July 31, 2017
Closed
can we disable future dates using any date/calendar control ?
I would like to show the calendar by default disabling future dates to avoid another code for validation
Version : Pega 7.1.9
Hi,
it is not disabling dates in the calendar itself but you could enforce validation just after selecting the date.
You have to do a bit of coding, very light.
In your property, select a validate rule called IsFutureDate. open it, private check in and save as IsPastDate and change the test from
return (theDate != null && theDate.after(new java.util.Date()));
to
if (theDate != null && theDate.before((new java.util.Date()))) {
return true;
} else {
theProperty.addMessage("This date cannot be in the future");
return false;
}
Now you property cannot be set to the future.
Create a new DateTime controle and add an action. OnChange = post.
Automatically if you change the date sing the control, it will use your validation
Damien