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

Q3 Prometheus DateTimePicker

1 Answer 101 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Sasa
Top achievements
Rank 1
Sasa asked on 09 Apr 2008, 10:47 AM

Hello.

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();                                   
            calendarIn.set_selectedDate(newDate);  
        }  
    }  
</script> 
<telerik:RadDateTimePicker ID="dateTimeIn" runat="server" Width="220px" EnableTyping="false" ClientEvents-OnDateSelected="In_DateSelected" /> 

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 10 Apr 2008, 06:04 PM
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" /> 
        </DateInput> 
</telerik:RadDatePicker> 


Greetings,
Maria Ilieva
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Calendar
Asked by
Sasa
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or