Created
September 30, 2014 11:17
-
-
Save ethyde/5d0df47141c740ecf828 to your computer and use it in GitHub Desktop.
jQuery UI datepicker non-working day hack :
http://www.4mghc.com/threads/205643-Can-the-jQuery-UI-Datepicker-be-made-to-disable-Saturdays-and-Sundays-and-holidays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("input").datepicker({ | |
beforeShowDay: nonWorkingDates, | |
numberOfMonths: 1, | |
minDate: '05/01/14', | |
firstDay: 1 | |
}); | |
function nonWorkingDates(date){ | |
var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6; | |
var closedDates = [[7,25, 2014], [8, 14, 2014]]; | |
var closedDays = [[Monday], [Tuesday]]; | |
for (var i = 0; i < closedDays.length; i++) { | |
if (day == closedDays[i][0]) { | |
return [false]; | |
} | |
} | |
for (i = 0; i < closedDates.length; i++) { | |
if (date.getMonth() == closedDates[i][0] - 1 && | |
date.getDate() == closedDates[i][1] && | |
date.getFullYear() == closedDates[i][2]) { | |
return [false]; | |
} | |
} | |
return [true]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment