DateTimePicker Problem

2 posts, 0 answers
  1. Jeff Tang
    Jeff Tang avatar
    54 posts
    Member since:
    Jun 2008

    Posted 15 Aug 2008 Link to this post

    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.
  2. Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 17 Aug 2008 Link to this post

    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:

    1 <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    2     <script type="text/javascript"
    3         function OnError(sender, args) { 
    4             sender.clear(); 
    5             sender.focus(); 
    6         } 
    7     </script> 
    8 </telerik:RadScriptBlock> 
    10 <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server"
    11     <DateInput> 
    12         <ClientEvents OnError="OnError" /> 
    13     </DateInput> 
    14 </telerik:RadDateTimePicker> 

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

    Kevin Babcock
Back to Top