Jquery datepicker - do not preselect dates

656 Views Asked by At

I have two jquery datepickers, one for selecting arrival date, the other for departure. The problem is I cannot seem to find out how NOT to have preselected dates. As soon as the datepicker is inited and I request the getDate(), it returns me a date. Without any user interaction.

The second problem is that once I select a date in the "arrival datepicker", it automatically sets the minDate for the "departure datepicker". That's nice, the problem is that it automatically selects this date, too. I do not want it to select the date, I just want it to disable all the days till the minDate day.

How to avoid this? (or just simply deselect the selected date) Thanks in advance!

The code is:

var a = $("#arrival_date_datepicker");
var d = $("#departure_date_datepicker");

a.datepicker({
    onSelect: function(date){
        d.datepicker("option", "minDate", date);
        d.datepicker("option", "defaultDate", null);
    },
    minDate: 0
});

d.datepicker({
    onSelect: function(date){

    },
    minDate: 0
});
0

There are 0 best solutions below