day in the past

1
0
-1

Hi,

created a field in a form requestdate which is a date field. Now i want to prevent that people select a day in the past and thus generate a message telling the user: You cannot select a date in the past, please select a proper date. I think i need to do that using a validator, but i am not sure whether there is something like "current_date" or "today" to indicate that requesteddate<current_date (or today)... Any ideas? thnx emveha

Comments

Submitted by yannick.lombardi on Wed, 08/20/2014 - 15:59

Hi, You can use this code :

Date today = new Date(); //It is automatically set to the current date
return !(requestedDate.getTime() < today.getTime());
Submitted by emveha on Thu, 08/21/2014 - 09:58

Hi Yannick,

while trying your suggested solution, the system is telling me that there is an issue: "today cannot be resolved. It may lead to runtime error". Any idea what is going wrong?? thnx

Submitted by emveha on Fri, 08/22/2014 - 10:16

if i use this script the system tells me: Today cannot be resolved. It may lead to runtime errors. Any ideas how to solve this thnx

No answers yet.
Notifications