Q3 Prometheus DateTimePicker

2 posts, 0 answers
  1. Sasa
    Sasa avatar
    12 posts
    Member since:
    Aug 2007

    Posted 09 Apr 2008 Link to this post


    I have a DateTimePicker control with set MinDate to "DateTime.Now". When a user selects a date, the calendar sets the time to 00:00, by default.

    Problem is: when a user selects today's date it will be invalid. So, I'd like to intercept this somehow and set the date to MinDate instead. The same thing is with the time picker - if user selects a time that is bellow minimum, I'd rather reset it to minimum value then getting the invalid red border.

    Here's a code I've tried, I guess I'm doing something wrong:

    <script language="javascript">  
        function In_DateSelected(sender, e)  
            var calendarIn = $find("<%= dateTimeIn.ClientID %>");  
            var newDate = e.get_newDate();  
            if(newDate == null)  
                newDate = calendarIn.get_minDate();                                   
    <telerik:RadDateTimePicker ID="dateTimeIn" runat="server" Width="220px" EnableTyping="false" ClientEvents-OnDateSelected="In_DateSelected" /> 

  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 10 Apr 2008 Link to this post

    Hello Sasa,

    You can achieve the desired functionality by handling the DateInput's OnError event client-side like this:
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server"
            <DateInput runat=server
            <ClientEvents OnError"In_DateSelected" /> 

    Maria Ilieva
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top