cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

How to disable previous dates in datepicker widget

sabharees
15-Moonstone

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. 

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

6 REPLIES 6

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

sabharees
15-Moonstone
(To:zyuan1)

Hi Thanks for you suggestions,
can i get sample code for validator ??

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

sabharees
15-Moonstone
(To:zyuan1)

Hi Thanks again for your ideas,

 

I also used this method long back but now i need to disable previousdays like how now we are disabling futuredays in widget properties.

I would like to know that type of smiliar approach or any other possiblities to do that.

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.

slangley
23-Emerald II
(To:sabharees)

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

Announcements


Top Tags