Skip to content

Instantly share code, notes, and snippets.

@vanbernaert
Last active November 3, 2015 11:31
Show Gist options
  • Save vanbernaert/4dd1557abda08e7be90a to your computer and use it in GitHub Desktop.
Save vanbernaert/4dd1557abda08e7be90a to your computer and use it in GitHub Desktop.
Gravity Forms: restrict days on datepicker
jQuery(function () {
// 0 = monday, 1 = tuesday, 2 = wednesday, 3 = thursday,
// 4=friday, 5 = saturday, 6=sunday
var daysToDisable = [2, 4, 5];
jQuery("#input_id_id").datepicker({
beforeShowDay: disableSpecificWeekDays
});
function disableSpecificWeekDays(date) {
var day = date.getDay();
for (i = 0; i < daysToDisable.length; i++) {
if (jQuery.inArray(day, daysToDisable) != -1) {
return [false];
}
}
return [true];
}
});
// source: http://codeasp.net/blogs/microsoft-net/767/jquery-datepicker-disable-specific-weekdays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment