Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to retrieve dates from my json and passing it to the function nationalDays(date).

XML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>cal</title>

    <link href="ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet" /><!--jquery ui css-->
    <script src="jquery-v1.11.0-min.js"></script><!--jquery js-->
    <script src="jquery-ui-v1.10.4-min.js"></script><!--jquery ui js-->
</head>
<body>
    <input id="Datepicker" type="text" onclick="javascript: PickDate();" />

    <script type="text/javascript">
        function PickDate() {
            var d = new Date();
            var natt = { "holidays": ['05/23/2014', '05/27/2014', '05/29/2014', '5/30/2014'] };
            var natDays = natt.holidays;

            function nationalDays(date) {
                var m = date.getMonth();
                var d = date.getDate();
                var y = date.getFullYear();

                for (i = 0; i < natDays.length; i++) {
                    if ((m == natDays[i][0] - 1) && (d == natDays[i][1]) && (y == natDays[i][2])) {
                        return [false];
                    }
                }
                return [true];
            }
            function noWeekendsOrHolidays(date) {
                var noWeekend = $.datepicker.noWeekends(date);
                if (noWeekend[0]) {
                    return nationalDays(date);
                } else {
                    return noWeekend;
                }
            }
            $("#Datepicker").datepicker({

                minDate: new Date('20 May 2014'),
                maxDate: "+60D",

                hideIfNoPrevNext: true,
                beforeShowDay: noWeekendsOrHolidays,
            });
            $("#Datepicker").datepicker('show');


        }
    </script>
</body>
</html>
Posted
Updated 20-May-14 18:26pm
v2

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