Please check below link and code.
<script>
function initializeBooking() {
$('#form_booking').ajaxSubmit({
target: '#result',
success: function () {
$('#result').fadeIn('slow');
}
});
return false;
}
// hotel nights.. available is 2, 3, 4, 5, 6, 7, 8, 9 nights.
var nights = 4;
// arrival weekday in hotel: monday = 1 ..... sunday = 7
var arrival = 2;
// flexbooking = no .. otherwise you can arrive when you want.
var flex_booking = 'no';
$(function () {
cal_start = new Date();
cal_start.setTime(cal_start.getTime() + (24 * 60 * 60 * 1000 * 1));
$("#datepicker_begin").datepicker({
beforeShowDay: function (date) {
weekday = date.getDay();
if (weekday == 0)
weekday = 7;
/*var start = weekday;
//var end = start;
for (i = 1; i > nights; i++)
{
alert(start);
if (end == 8){
end = 1;
}
}*/
if (flex_booking == 'no') {
if (weekday == arrival) {
result = [true, "relevant"];
// clickable for the arrival day
} else if (weekday > arrival && weekday <= (arrival + nights)) {
result = [false, "relevant"]; // red but no clickable for the days you are staying in the hotel
} else {
result = [false, ""];
// normal days outside the booking range. could be possible nights > 6 that this is not set and everything is red
}
} else {
result = [true, "relevant"];
}
return result;
},
altField: "#date_begin",
altFormat: "@",
showOtherMonths: false,
selectOtherMonths: false,
numberOfMonths: 3,
dateFormat: "dd.mm.yy",
firstDay: 1,
minDate: cal_start,
maxDate: "+12m",
onSelect: function () {
begin = eval($("#date_begin").val());
start = new Date();
start.setTime(begin);
days = nights;
end = new Date();
end.setTime(begin + (24 * 60 * 60 * 1000 * days));
$("#date_end").val(begin + (24 * 60 * 60 * 1000 * days));
after = new Date();
after.setTime(begin + (24 * 60 * 60 * 1000 * days) + (24 * 60 * 60 * 1000));
$("#datepicker_end").val(('0' + end.getDate()).slice(-2) + '.' + ('0' + (end.getMonth() + 1)).slice(-2) + '.' + end.getFullYear());
$("#nights_span").html(new Date(end - begin) / 1000 / 60 / 60 / 24);
$("#datepicker_end").datepicker("destroy");
$("#datepicker_end").datepicker({
beforeShowDay: function (date) {
return [false, ""];
},
altField: "#date_end",
altFormat: "@",
minDate: new Date(end),
maxDate: new Date(after),
showOtherMonths: false,
selectOtherMonths: false,
numberOfMonths: 1,
dateFormat: "dd.mm.yy",
firstDay: 1,
onSelect: function (dateText) {
initializeBooking();
}
});
initializeBooking();
}
});
});
</script>