Restrict keyboard input in the DatePicker control to numerics and forward slace

1 Answer 61 Views
Date/Time Pickers
Chhavi
Top achievements
Rank 1
Chhavi asked on 18 Oct 2022, 11:54 AM | edited on 18 Oct 2022, 11:56 AM

Hi ,

We have a validation related requirement on the datepicker control. The datepicker control should not allow alphabets or special chars to be keyed in.  It should allow only numerics, backspace and forward slaces keys for example: 10/10/2022. 

The requirement is to validate it as soon as its keyed in instead of when the control lose focus.

Because datepicker control does not have keydown/key press event, I added a jquery script as below and it works fine but we dont want to repeat the script for all the date pickers controls on different screens across the project. Is there any feature of the control it self that can be used everywhere??

 

Thanks,

Chhavi

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 21 Oct 2022, 08:28 AM

Hi,

 

Thank you for contacting us.

You can achieve this requirement using the .DateInput(true) property provided by the DatePicker component:
https://docs.telerik.com/kendo-ui/api/javascript/ui/timepicker/configuration/dateinput

Here is a live sample I've prepared for you to check:
https://dojo.telerik.com/UBIhALod

Can you give this setting a try and let me know if it helps you?

 

Regards,
Eyup
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Date/Time Pickers
Asked by
Chhavi
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or