Reputation: 23
I need not to be able to select 3 days of the current date, Saturdays and Sundays are not selectable. How can I make the 3 days not selectable not count on Saturdays and Sundays? example if the day of admission is Friday you can select until Wednesday (without counting Saturdays and Sundays) thanks in advance.
this is what I have https://codepen.io/anon/pen/xzNrGx?editors=1000
$( "#datepicker" ).datepicker({
dateFormat: 'dd/mm/yy',
firstDay: 1,
minDate: "+3D",
beforeShowDay: function(d) {
var day = d.getDay();
return [(day != 0 && day != 6)]
}
});
Upvotes: 2
Views: 48
Reputation: 11732
Try something like this:
<script>
$( "#datepicker" ).datepicker({
dateFormat: 'dd/mm/yy',
firstDay: 1,
minDate: getMinDate(),
beforeShowDay: function(d) {
var day = d.getDay();
return [(day != 0 && day != 6)]
}
});
function getMinDate() {
var date = new Date();
var day = date.getDay();
var addedDays = [4, 3, 3, 3, 5, 5, 5];
return '+' + addedDays[day] + 'd';
}
</script>
Upvotes: 1