I use a script (1) from the jquery UI datepicker sample site. It gives the ability to select a data range. I added the line "minDate: 0" that disables all dates before today. I want to combine this with a function (2) that I found at Stack Overflow. It disables an array of dates from the calendar.
I tried to combine these scripts but it I cannot make it all work together (select date range, disables dates before today and disables array of dates). Help would be very much appreciated.
(1) Code from jquery UI datepicker sample site. This pen has a working sample.
$(function() {
$( "#from" ).datepicker({
minDate: 0,
changeMonth: true,
numberOfMonths: 2,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
minDate: 0,
changeMonth: true,
numberOfMonths: 2,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
</head>
<body>
<label for="from">From</label>
<input type="text" id="from" name="from">
<label for="to">to</label>
<input type="text" id="to" name="to">
</body>
(2) Script that disables certain dates (link) (see also this fiddle)
var array = ["2013-03-14","2013-03-15","2013-03-16"]
$('input').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ array.indexOf(string) == -1 ]
}
});