Reputation: 897
Can someone let me know if it's possible to disable dates in the datepicker by passing day names to it?
Eg. I would like to only allow dates that fall on a Wednesday, Friday and Sunday and grey out all other dates.
Is this possible?
Thanks
Upvotes: 0
Views: 816
Reputation: 69905
You can use beforeShowDay
event of datepicker to disable days conditionally. Try this
$(document).ready(function() {
$('#datepicker').datepicker({
beforeShowDay: filterDays
});
});
// getDay() method returns the day of the week (from 0 to 6) where
// Sunday is 0, Monday is 1, and so on.
function filterDays(date) {
var day = date.getDay();
//return true only if day is Wed or Fri or Sun
return (day == 3 || day == 5 || day == 0);
}
Upvotes: 1