I guys i\'m using a datetimepicker by trentrichardson.com.
I have a form with two input fields : from and to and i want to be able
In jQuery UI datepicker
there is many Functions which are helpful to set minDate
or maxDate
dynamically like onSelect
, onClose
.
demo of onClose
is already provided in @Tanvir's answer see here: datepicker onClose example
So i will give you example of onSelect
.
before it i will tell you difference between onSelect
and onclose
, as Name suggests onSelect
fire just after user selects a date and onClose
fire when datepicker closes after date selection, that's all.
here we have two datepicker pickupdate1
and pickupdate2
, and we want to set selected date of pickupdate1
to be minDate of pickupdate2
and it should be dynamic, so here's the code:
$("#pickupdate1").datepicker({
dateFormat: "dd-mm-yy",
onSelect: function (selectedDate) {
$('#pickupdate2').datepicker('option', 'minDate', selectedDate);
}
});
$("#pickupdate2").datepicker({
dateFormat: "dd-mm-yy",
});