0

I want to disable first saturday of every month + I want to disable all sundays I have tried below code which will only disable every sundays.How can I disable first saturday of every month ?? Below is the code I have tried : $(function () {

        $("#txtDate").datepicker({
            beforeShowDay: noSunday
        });
        function noSunday(date) {
            var day = date.getDay();
            return [(day > 0), ''];
        };
    });
0

1 Answer 1

1

You have done a pretty good work on disabling the Sunday as mentioned in your question. As (day > 0) will enable date except for the Sunday's. Now, for adding the restriction for the first Monday of the month you can use,

var day = date.getDay();
day.getDate(); //Returns the numbering of date. e.g Jan 1 will return 1 , Jan 2 will return 2 and so on.

So if you want to check for First Monday you need to do,

!(day==6 && date.getDate() <= 7)
//Day==6 denotes Saturday

So, The complete code will look like,

function disableDate(date) {
      var day = date.getDay();
      return [ (day!=0 && !(day==6 && date.getDate() <= 7)), ''];
 }

See the demo here.

Sign up to request clarification or add additional context in comments.

3 Comments

I want all Saturday's to be disabled,not .MONDAYS. Also I want to show first saturday,rest of saturday should get disabled.
So, What seems to be the problem just restructured the equation above to get the desired result.
Yes i misunderstood the problem and disabled the Monday instead. But it conflict with your comment above : How can I disable first saturday of every month ??

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.