Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save deckerweb/1e17c328b5f36adfecb5 to your computer and use it in GitHub Desktop.

Select an option

Save deckerweb/1e17c328b5f36adfecb5 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
@carnini
Copy link

carnini commented May 17, 2023

Thanks, this is just what I needed in order to remove specific days from a Gravity Form Date picker in Wordpress. What I like about this solution is it allows you to trigger it only for a specific ID unlike other solutions that change all date pickers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment