Sunday only on JQuery Datepicker?

AIM: only allow users to select Sunday in datpicker calendar.

Currently, I almost did it, except for the reasons that every day except Sunday works. When I use 7 for Sunday in the code below, the whole calendar is fuzzy, any other day works fine.

$(document).ready(function() {

    $("#datepicker2").datepicker({ 
        autoSize: true,         // automatically resize the input field 
        altFormat: 'yy-mm-dd',  // Date Format used
        firstDay: 1, // Start with Monday
        beforeShowDay: function(date)

        { return [date.getDay() == 7,''];}}); // Allow only one day a week
});

      

Question: How can I authorize Sunday picks?

+3


source to share


1 answer


Date.getDay()

returns a value in a range 0-6

, not 1-7

.



beforeShowDay: function(date) {
    return [date.getDay() === 0,''];
}

      

+7


source







All Articles