Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to Disable 2nd saturday fourthday saturday and sunday with holiday date disable using j query calendar
Posted
Updated 8-Mar-16 17:31pm

1 solution

Here i have made a simple example :

html :
htm
<input type="text" id="txtCal" />


Jquery code
JavaScript
  var holiday = [[12, 30, 2015], [1, 1, 2016]]; //here get your list of holiday 

        $("#txtCal").datepicker({
            beforeShowDay: nonWorkingDays,
            numberOfMonths: 1,
            minDate: '01/01/2011',
            maxDate: '+5M',
            firstDay: 1
        });

        function nonWorkingDays(date) {

            var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
            var week = 0 | date.getDate() / 7 //get the week
         
            //check if it's second week or fourth week
            if (week == 1 || week == 3) {
                if (day == 6)  { //check for satruday
                    return [false];
                }
            }

            //check for sunday
            if (day == 0)
            {
                return [false];
            }
          
//check for holidays
            for (i = 0; i < holiday.length; i++) {
                if (date.getMonth() == holiday[i][0] - 1 &&
                date.getDate() == holiday[i][1] &&
                date.getFullYear() == holiday[i][2]) {
                    return [false];
                }
            }

            return [true];
        }

Good luck
 
Share this answer
 
v4
Comments
Member 12363175 3-Mar-16 0:44am    
can i have jquery version or send me the link of jquery
Member 12363175 4-Mar-16 6:12am    
the above code is not working dude
Raje_ 4-Mar-16 8:01am    
Are you sure it's not working. Have you written your code correctly?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900