I have been trying to implement some additional code to disable a range of dates in the future on my date range picker, from my research I believe I need to use beforeShowDay
, have the dates in an array
and return a false if the dates are in the array
but each time I try to spanner
in some code it breaks the pickers. I have to confess I don't know Javascript very well at all and only use it with plugins when I have to, any help would be gratefully received.
var dateToday = new Date();
var dates = $("#from, #to").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
minDate: dateToday,
onSelect: function(selectedDate) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $(this).data("datepicker"),
date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
}
});
I would like to disable from the 2nd of December 2017
to the January 27th 2018