I am trying to limit an input date so that a date more than 3 days cannot be selected, starting with the day after the current one and also that Sundays are not selectable either. My problem is that both restrictions collide and it counts Sundays as one more day within the selectable ones but having deactivated Sunday it is not clickable but it does not add one more day than if it is selectable.
JQuery function
$(document).ready(function() {
var tomorrow = new Date();
var finfecha = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
finfecha.setDate(tomorrow.getDate() + 2);
$('#id_fecha_entrega').datepicker({minDate: tomorrow, maxDate: finfecha, beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 0), ''];
}});
$.datepicker.regional['es'] = {
closeText: 'Cerrar',
prevText: '<Ant',
nextText: 'Sig>',
currentText: 'Hoy',
monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Juv', 'Vie', 'Sáb'],
dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sá'],
weekHeader: 'Sm',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
};
$.datepicker.setDefaults($.datepicker.regional['es']);
});
In order to get what I wanted I had to check what day of the week it was to add one more day to the list of days that I could select, since there is no way to "skip" a day of the week.
I put my code as it has been: