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

DateTimePicker Problem

1 Answer 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jeff Tang
Top achievements
Rank 1
Jeff Tang asked on 15 Aug 2008, 06:19 AM
I have a question about DateTimePicker. Is there any function can validate the format of the input date? The problem is that even I type this "abcde" in the input area of the DateTimePicker, it still let me go when I out-focus the DateTimePicker. Thanks.

1 Answer, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 18 Aug 2008, 02:05 AM
Hello Jeff,

The nice thing about the RadDateTimePicker (and other related date/time picker controls) is that it automatically validates input for you. When input is invalid, the control is highlighted (by default, in red) and a warning image is displayed inside the textbox. This functionality can be turned off if you'd like to manually validate the input by setting the DateInput-CausesValidation property to false. If you'd like to clear the invalid input and force the user focus back into the textbox, you can use the DateInput-ClientEvents-OnError event to do so. Here is an example:

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    <script type="text/javascript"
        function OnError(sender, args) { 
            sender.clear(); 
            sender.focus(); 
        } 
    </script> 
</telerik:RadScriptBlock> 
 
<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server"
    <DateInput> 
        <ClientEvents OnError="OnError" /> 
    </DateInput> 
</telerik:RadDateTimePicker> 


I hope this was helpful. If you have any further questions, please don't hesitate to ask.

Sincerely,
Kevin Babcock
Tags
General Discussions
Asked by
Jeff Tang
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Share this question
or