Skip to main content
16-Pearl
May 6, 2020
Solved

Disable dates in Datepicker after today's date

  • May 6, 2020
  • 4 replies
  • 5749 views

Hi ,

i am looking for disabling the dates after current date . how can we do it in TWX 8.5 .

 

Thanks 

Best answer by Constantine
Here’s the code, it’s trivial:

endDate > new Date();

Use Validator function, enable its “Auto Evaluate” and bind its result to Disabled property of your primary action button, so that the user cannot continue if the selected date is in the future.

To improve user experience you can also add a Status Message function, which says something like “Please select a date in the past” and bind its Show service to True event of the validator.

4 replies

Support
May 7, 2020

@VaibhavShinde.

 

Can you please provide the details of your use case?  It's not clear what you are attempting to do.

 

Regards.

 

--Sharon

22-Sapphire I
May 7, 2020

I don't remember seeing that as an option.

You could always add validation.

Else you would need a custom widget or do the date picking with different controls that you have more control over.

16-Pearl
May 8, 2020

Hi PaiChung,

ok , how can i call a validation script while selecting date in date picker ? do i need any event here to call script?

 

Thanks

 

 

22-Sapphire I
May 8, 2020

I believe the date picker may have an 'on change' event, if not, then you would use your 'button click' that is invoking the service to run with the date selected.

In  the mashup you can then utilize the Validation function, so the 'event' would invoke the validation function and form there either inform the user (status message) or invoke the service you want to run.

18-Opal
May 10, 2020

Hello @VaibhavShinde,

 

Just bind the Output of the date/time picker to a validator parameter and select "Auto Evaluate" checkbox -- then this validator will be triggered every time you select a date.

 

Regards,
Constantine

6-Contributor
May 10, 2020

Hi VaibhavShinde

I am reading your requirement as "do not allow" the users to pick the future date. In situations like selecting a date based on "Create date", create date cannot be a future date. Hence the date picker future dates should be greyed out. Is this the behavior you would like to have.

16-Pearl
May 11, 2020

Hi @Swamy_Senthil 

 

Yes i have same requirement as you said. just i have input parameter named 'endDate' . i have to use function to validate the selected date. could you provide pseudo code in function? 

 

thanks

18-Opal
May 11, 2020
Here’s the code, it’s trivial:

endDate > new Date();

Use Validator function, enable its “Auto Evaluate” and bind its result to Disabled property of your primary action button, so that the user cannot continue if the selected date is in the future.

To improve user experience you can also add a Status Message function, which says something like “Please select a date in the past” and bind its Show service to True event of the validator.