This is a migrated thread and some comments may be shown as answers.

Kendo datepicker prevent change on condition

3 Answers 382 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Jaanus
Top achievements
Rank 1
Jaanus asked on 03 Jan 2019, 09:22 AM

How can I conditonally stop the change on datepicker?

 

This is what I tried, but it is not working.

https://dojo.telerik.com/opAqoqEq

3 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 07 Jan 2019, 09:57 AM
Hi Jaanus,

To achieve the desired outcome, handle the close event:
In the event handler, based on a condition, prevent the default behavior and reset the invalid date. For example:

Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jaanus
Top achievements
Rank 1
answered on 07 Jan 2019, 11:36 AM

The users usually change the value by just writing the value, not opening the datepicker.

How can I handle it then?

0
Tsvetomir
Telerik team
answered on 08 Jan 2019, 04:59 PM
Hi Jaanus,

If you would like to have an input which restricts the user from typing in invalid data, then you can make use of the DateInput setting of the Kendo UI DatePicker.

https://docs.telerik.com/kendo-ui/api/javascript/ui/datetimepicker/configuration/dateinput

This would show the user what is the pattern for the date and it will automatically restrict them from submitting invalid data. 

It is important to point out that the change event of the DatePicker is triggered when the date from the calendar is changed, rather than on the change of the input. There is an option to attach jQuery event handlers to the Kendo UI widgets, but even on the keypress event, it would be too late to cancel the changes because the value will be already in the input. 

Let me know in case additional questions arise.


Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Date/Time Pickers
Asked by
Jaanus
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Jaanus
Top achievements
Rank 1
Share this question
or