The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Restrict user to select past 24 hrs in date/time field?

bharathk1116
Tera Contributor

I have a date/time field. Need to restrict it from selecting less than 24 hours.

 

For ex :

 today is  17th June 9:10:00  and users should not be allowed to select less than 16th June 9:10:00

i.e if a use selects 16th June 9:09:00 --> It should throw an error

4 REPLIES 4

Aman Kumar S
Kilo Patron

You can have a UI policy in place, something as

Resolved - relative - before - 24 hours from now

And add the script by marking Run script as true and add below line execute if true.

g_form.showFieldMsg("field_name","Select within 24 hours","error");

capture74.PNG

Best Regards
Aman Kumar

Hi,

 

Can you pl once again confirm that it is before 24 hours from now or ago.

 

Because I am checking if the time is less than 24 hours ago -> it should give an error.

@bharathk1116 

Oh the logic that I shared would show error if date is selected beyond 24 hours.

The logic is fine, what you can do instead of Execute, if true, put the script in Execute, if false

Make sure execute if false is checked in the UI policy.

 

g_form.showFieldMsg("field_name","Select within 24 hours","error");

Best Regards
Aman Kumar

Theo BOULANGER
Giga Guru

Hello @bharathk1116 

 

The best solution is to use an advance qualifier for your field. Indeed you can create you own custom filter in a scriptInclude and call it in advance qualifier.

It'll not show the day you don't want in the calendar so the user experience will be better than getting an error.

If you need some help to do that tell me.

 

Mark it as helpfull if it is 🙂

 

Regards,

Theo