Unplanned
Last Updated: 29 Mar 2024 10:46 by Austin
NovaStor
Created on: 08 Mar 2022 21:03
Category: DateTimePicker
Type: Bug Report
6
Do not revert to the previous value if an invalid date was entered

Hi.

When entering an invalid date in a DateTimePicker, the component will automatically revert the entered value back to its previous valid value.

I didn't expect this because the user may type in an invalid date, and continue to the next input control within the form, and not notice the error that was briefly displayed.

The issue can be reproduced in the DateTimePicker Demo here: https://demos.telerik.com/blazor-ui/datetimepicker/validation

Steps to reproduce:

1. Click in the day part of the date.

2. Enter 13

3. Enter 2100

4. Press the Tab key

5. Notice the date is automatically reverted (back) to 10/13/2019.

 

I expected the date to be set to 10/13/2100 with the input validation errors visible to the user after pressing the Tab key in step 4.

 

I've categorized this issue as a bug because otherwise, the form can be submitted with a value that the user did not enter.

 

If this behavior cannot be changed from being the default behavior, then there should be an option to prevent this behavior from happening.

 

Thank you.

2 comments
Austin
Posted on: 29 Mar 2024 10:46

I also desire a feature change with this control. My scenario is I am passing a Min() and Max(), but when the date typed is outside these dates, it automatically changes the the date on you.  If you are not fully paying attention you will be left with a date you did not type in. 

If possible it would be nice to have a configuration option to also call an EventCallback on invalid date, so I can create my own error message or set the date myself.

ADMIN
Dimo
Posted on: 16 Mar 2022 16:17

Hello,

The current behavior is by design, but we discussed it and agree we may need to change it or provide a configuration option.

What you can do now is bind the DatePicker to a nullable DateTime. In this case, an invalid value will clear the component textbox and the validator will kick in.

Regards,
Dimo
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/.