Reputation: 176
I am using jquery Ui Date picker , i am struck with strange requirement given by client, help me in going forward.
In my scenario, i have two date pickers*(from,to Date)* ,now the requirement is i need to select only the past days only(done),and the second one is if i select the from date in one month and to date also should be in the same month only (eg: if i select from date in may month and in to month i have to select only in the may month only remaining has to disable).
fiddle:jsfiddle.net/vamsikrishna123/hFnf8/
Upvotes: 1
Views: 1655
Reputation: 318182
You'd do that like so:
$("#from").datepicker({
defaultDate: "+1w",
changeMonth: true,
onClose: function (selectedDate) {
$("#to").datepicker("option", "minDate", selectedDate);
var date = $("#from").datepicker('getDate');
var d = new Date(date.getFullYear(), date.getMonth() + 1, 0);
$("#to").datepicker("option", "maxDate", d);
}
});
Upvotes: 1