Skip to main content
Oct 20, 2020 5:48 AM UTC
Solved

How to disable previous dates in datepicker widget

I need to select dates only from September month and need to disable rest of the previous dates in date picker widget. 

zyuan1Answer
Oct 27, 2020 7:05 AM UTC

Only in DateTimePicker "Range" selection condition, the end date cannot be earlier than start date, will the dates in the picker be disabled and become grey.

 

And I can't find ways to compare time in Expression any more. Didn't know if I used wrong script or it's been disabled.   Time1 - Time2 = time difference (integer) used to work, and then (Time1 - Time2)>0 can be used in time comparison.

6 replies

Oct 20, 2020 6:33 AM UTC

You may not able to disable widget from selecting the time before today, but you can use a Validator Function in the mashup, to identify if the new StartDate input is earlier than the limit (trigger by Widget's Changed event), if so, a Warning message will show up;

You may also trigger a service to assign today's time to the widget if the startDate is earlier

sabhareesAuthor
Oct 20, 2020 6:52 AM UTC
Hi Thanks for you suggestions,
can i get sample code for validator ??
Oct 20, 2020 8:09 AM UTC

Gave up using Expression, can't remember how to make it work.

 

I actually did this:

1. create a service in Thing, with script var result = time<new Date();  time is the input, output is boolean;

2. Add this service to mashup, add the timepicker to its input

3. create a Label widget saying "Time should not be earlier than today"

4. bind the service result to "Visible" of the Label widget, and trigger the service by timepicker "Change" event

 

Now it works

Nov 4, 2020 4:31 PM UTC

Hi @sabharees.

 

If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon