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

minimum value for datetimepicker (client side)

1 Answer 110 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Alex Lawson
Top achievements
Rank 1
Alex Lawson asked on 07 Jul 2008, 08:31 AM
I want to limit the entered time value to a min-max range fro the datetimepicker, so that if a user enters 7:03 am it will be corrected to 9:00am for example.

Is this achievable in client side JS code?

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 Jul 2008, 10:52 AM
Hi Alex,

It is possible to catch the ClientEvents of the DateInput as shown below:
<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server"
    <DateInput runat="server"
        <ClientEvents OnValueChanged="CheckTime" OnMouseOut="CheckTime"> </ClientEvents> 
    </DateInput> 
</telerik:RadDateTimePicker> 

Afterward you can choose how to handle the event from JavaScript. Here is a possible approach:
var time = new Date(sender.GetDisplayValue());  
minTime.setDate(time.getDate()); 
maxTime.setDate(time.getDate()); 
 
if(time < minTime) 
    time.setTime(minTime.getTime()); 
    sender.set_value(time.toString());         
else if (time > maxTime) 
    time.setTime(maxTime.getTime()); 
    sender.set_value(time.toString());         

Kind regards,
Daniel
the Telerik team

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