Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Datepicker - only select mondays and thursdays

I have the following code which only allows users to select Mondays from jquery datepicker.

I want to adapt this to be able to select mondays and thursdays.

Any ideas?

beforeShowDay: function(date){ return [date.getDay() == 1,""]}
like image 903
Tom Avatar asked Sep 27 '10 15:09

Tom


2 Answers

You can add an or (||) in there, like this:

beforeShowDay: function(date){ 
  var day = date.getDay(); 
  return [day == 1 || day == 4,""];
}

This only incurs the cost of .getDay() once per date shown, not that it's an expensive operation anyway, but no reason not to be efficient.

like image 123
Nick Craver Avatar answered Nov 17 '22 09:11

Nick Craver


try this

beforeShowDay: function(date)
{ return [(date.getDay() == 1 || date.getDay() == 4), ""]; }
like image 3
Pramendra Gupta Avatar answered Nov 17 '22 11:11

Pramendra Gupta