Timepicker says invalid when typing in field

1 Answer 205 Views
Date/Time Pickers
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Lee asked on 03 Aug 2021, 08:12 PM | edited on 03 Aug 2021, 09:20 PM

I have a timepicker field. The built in required rule is ignored since I am using a dateInput field for the masking. When the user types something wrong in the field such as "1:mm PM" (meaning they just typed a 1 in the field) it throws an error that says "A time is required". The console logs out "null" as the value of the time picker field. When the user then goes and types in the 00 so it reads "1:00 PM" it  still says "A time is required" and still logs out "null" as the value. If the user then changes anything in the field to some other valid time the message goes away an it validates. How do I fix this?

Here is a Dojo demonstrating the issue:

https://dojo.telerik.com/@dojolee/AyuyAtaG/3

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 06 Aug 2021, 08:59 AM

Hello, Lee,

Thank you for the provided Dojo.

The issue occurs because the validation is triggered before the value of the TimePicker is updated. Generally speaking it is recommended that you let the Kendo Validator handle the validation process, however if you want to do it manually, you'll have to choose a different event to trigger the validation.

For example the blur event instead of change.

  $("#myForm input").on("blur", function () {
        myValidator.validateInput($(this))
    });

Updated Dojo:

https://dojo.telerik.com/@gdenchev/oMACaJiQ 

Let me know if you have any questions.

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Date/Time Pickers
Asked by
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Answers by
Georgi Denchev
Telerik team
Share this question
or