I have two RadDateTimePickers inside a RadGrid's <EditItemTemplate /> which represents a start/end date as such:
The ClientEvents-OnDateSelected script looks like this:
Since it is in a grid I use a hidden field that sets the Id of the end date element when the grid goes into edit mode so when a start date is selected I can set the mininumum date of the end date picker - this whole process works fine.
The problem I am encountering is when you select a date (say 8/31/2011) and select a time (say 7:00 PM) on the start date selector, the end date calendar has 8/31 as an available option, but you can't select it because it defaults to 8/31/2011 12:00:00AM which is before 7:00PM, thus invalid. This makes sense, but how can I make the end date's minimum value detect that it should be 8/31/2011 @ 7:00PM meaning if the end user selects 8/31 it automatically selects 7:00PM for the time? Naturally if they select an end date of 9/1 the default time would still be 12:00AM since that is after 8/31 @ 7:00PM.
<
tr
>
<
td
><
p
><
strong
>Start Date: </
strong
></
p
></
td
>
<
td
>
<
telerik:RadDateTimePicker
runat
=
"server"
ID
=
"rdtpStartDate"
Skin
=
"Windows7"
DbSelectedDate='<%#Bind("StartDate") %>' ClientEvents-OnDateSelected="dateSelected" />
<
asp:RequiredFieldValidator
runat
=
"server"
Display
=
"None"
ErrorMessage
=
"Start Date is required."
EnableClientScript
=
"true"
ControlToValidate
=
"rdtpStartDate"
/>
</
td
>
</
tr
>
<
tr
>
<
td
><
p
><
strong
>End Date: </
strong
></
p
></
td
>
<
td
>
<
telerik:RadDateTimePicker
runat
=
"server"
ID
=
"rdtpEndDate"
Skin
=
"Windows7"
DbSelectedDate='<%#Bind("EndDate") %>' />
<
asp:RequiredFieldValidator
runat
=
"server"
Display
=
"None"
ErrorMessage
=
"End Date is required."
EnableClientScript
=
"true"
ControlToValidate
=
"rdtpEndDate"
/>
</
td
>
</
tr
>
The ClientEvents-OnDateSelected script looks like this:
<
script
language
=
"javascript"
type
=
"text/javascript"
>
function dateSelected(sender, args) {
var hv = document.getElementById('<%=this.hvEndDateId.ClientID %>').value;
var edp = $find(hv);
var newDate = sender.get_selectedDate();
edp.set_minDate(newDate);
}
</
script
>
Since it is in a grid I use a hidden field that sets the Id of the end date element when the grid goes into edit mode so when a start date is selected I can set the mininumum date of the end date picker - this whole process works fine.
The problem I am encountering is when you select a date (say 8/31/2011) and select a time (say 7:00 PM) on the start date selector, the end date calendar has 8/31 as an available option, but you can't select it because it defaults to 8/31/2011 12:00:00AM which is before 7:00PM, thus invalid. This makes sense, but how can I make the end date's minimum value detect that it should be 8/31/2011 @ 7:00PM meaning if the end user selects 8/31 it automatically selects 7:00PM for the time? Naturally if they select an end date of 9/1 the default time would still be 12:00AM since that is after 8/31 @ 7:00PM.