user2637639
user2637639

Reputation: 47

how to disable all dates except Wednesday and Sunday dates in Jquery Ui Datepicker

I am using Jquery Ui Datepicker. I want to disable all dates except Wednesday and Sunday Dates. I wrote code like below. But it works only for Wednesday dates. And it displays from next month Onwards.I want it enable current month also.

<script>
$(function() {
$( "#datepicker" ).datepicker({
dateFormat: 'dd-mm-yy',
    minDate: 1,
    beforeShowDay: enableWednesday,

});
});
function enableWednesday(date) {
    var day = date.getDay();
    return [(day == 3), ''];
}

</script>

Please help me to enable all Wednesday and Sunday dates for current month also.Thanks in advance

Upvotes: 0

Views: 4624

Answers (2)

user2496033
user2496033

Reputation:

Please refer the following url Disable specific days of the week on jQuery UI datepicker

Upvotes: 0

Sridhar R
Sridhar R

Reputation: 20428

Try this code

$(function(){
        $("#datepicker").datepicker(
            {
            beforeShowDay: function (date) {

            if (date.getDay() == 0 || date.getDay() == 3) {
                return [true, ''];
            }
            return [false, ''];
           }
        });
    });

Upvotes: 2

Related Questions