我正在尝试从日历控件中选择的日期计算天数。如果 Javascript 中有任何功能,请告诉我。
<telerik:RadDatePicker ID="dtStart" runat="server" Culture="English (United States)"
MinDate="0001-01-01" Enabled="true">
<DateInput ID="DateInput2" runat="server" DisplayDateFormat="MM/dd/yyyy" DateFormat="MM/dd/yyyy">
</DateInput>
<ClientEvents OnDateSelected="DateSelected" />
</telerik:RadDatePicker>
<telerik:RadDatePicker ID="dtEndDate" runat="server" Culture="English (United States)"
MinDate="0001-01-01" Enabled="true">
<DateInput ID="DateInput3" runat="server" DisplayDateFormat="MM/dd/yyyy" DateFormat="MM/dd/yyyy">
</DateInput>
<ClientEvents OnDateSelected="DateSelected" />
</telerik:RadDatePicker>
function DateSelected(sender, eventArgs) {
var startDate = $find('<%=dtStart.ClientID%>');
var endDate = $find('<%=dtEndDate.ClientID%>');
if ((startDate.get_selectedDate() != null) && (endDate.get_selectedDate() != null)) {
var days = (startDate.get_selectedDate() - endDate.get_selectedDate());
}
}