Restrict Previous Dates in DateTime Picker

Posted by Rama Sagar under jQuery on 10/11/2013 | Points: 10 | Views : 1306 | Status : [Member] [MVP] | Replies : 2
Is it possible to have the DateTimePicker block out past dates from being selected, only allowing todays, tomorrow and future dates in Jquery ...


<script>



var startDateTextBox = $('#<%=txtStartDate.ClientID%>');
var endDateTextBox = $('#<%=txtEndDate.ClientID%>');

startDateTextBox.datetimepicker({
onClose: function (dateText, inst) {
if (endDateTextBox.val() != '') {
var testStartDate = startDateTextBox.datetimepicker('getDate');
var testEndDate = endDateTextBox.datetimepicker('getDate');
if (testStartDate > testEndDate)
endDateTextBox.datetimepicker('setDate', testStartDate);


}

else {
endDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime) {
endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate'));

}
});
endDateTextBox.datetimepicker({
onClose: function (dateText, inst) {
if (startDateTextBox.val() != '') {
var testStartDate = startDateTextBox.datetimepicker('getDate');
var testEndDate = endDateTextBox.datetimepicker('getDate');
if (testStartDate > testEndDate)
startDateTextBox.datetimepicker('setDate', testEndDate);
}
else {
startDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime) {
startDateTextBox.datetimepicker('option', 'maxDate', endDateTextBox.datetimepicker('getDate'));

}
});
</script>


ramasagar


Responses

Posted by: Brahmam on: 10/11/2013 [Member] Starter | Points: 25

Up
0
Down
Use Yahoo Calender controls working fine

brahmam

Rama Sagar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/11/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer his link
http://stackoverflow.com/questions/8356358/jquery-date-picker-disable-past-dates
http://forum.jquery.com/topic/datepicker-restrict-dynamically-dates

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Rama Sagar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response