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

How do I tell if a DatePicker contains an invalid date

2 Answers 158 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 02 Feb 2009, 09:37 PM
We have a page with a number of DatePickers and a submit button.

The DatePickers must contain a valid date, or they can be blank.

When a user enters an invalid date into a DatePicker field, and then switches focus to another field the DatePicker displays its contents in red, and adds a little "!" icon.

If the user clicks on the submit button while a DatePicker fields contains an invalid date, how do I tell in the code-behind that a DatePicker field contains invalid data?  In this case, SelectedDate is null, but SelectedDate is null if the field is blank, so that's no help.

I need to be able to distinguish between whether a DateField is empty or whether it contains an invalid value, from the server side, and I can see no way of doing so.

2 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 05 Feb 2009, 11:47 AM
Hi Jeff,

One possible option in this case would be to attach to the onError client side handler. This will allow you to detect the event when the user has entered erroneous data.
I hope this helps.

Regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeff
Top achievements
Rank 1
answered on 05 Feb 2009, 09:05 PM
That does fix the problem.
Tags
Calendar
Asked by
Jeff
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or