0

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

1 Answer 1

1

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);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.