0

I need assistance/guidance on 2 things. First, I need to know how to grey out days from a jquery datepicker and only return Monday thru Friday Days.

I have a simple HTML form that requires the selection of date. I would like to allow selections of one date. When the user enters any single date(Monday to Friday of whatever week in calendar), I would like to return the rest of the days in that week.

egbrad
  • 2,387
  • 2
  • 23
  • 27
Alex51482
  • 133
  • 1
  • 4

1 Answers1

1

The beforeShowDay function can be used to enable/disable certain dates.

beforeShowDay: function(dt){
    var day = dt.getDay();
    var isWeekend = (day == 6) || (day == 0);
    return [!isWeekend];
}

FIDDLE

egbrad
  • 2,387
  • 2
  • 23
  • 27
  • How can I return a range of dates in the selected day? Example: If I select April 15, 2013, I would like to return the selected date and April 16, 2013, April 17, 2013, April 18, 2013, and April 19. – Alex51482 Apr 15 '13 at 19:04
  • Same thing if I select April 17, 2013, I would like to return:April 15, 2013, April 16, 2013, April 17, 2013, April 18, 2013, and April 19. – Alex51482 Apr 15 '13 at 19:05
  • You can use the [onSelect](http://api.jqueryui.com/datepicker/#option-onSelect) function and then do math to calculate Monday and Friday based on the current day. I went ahead and [updated the fiddle](http://jsfiddle.net/SKqJH/7/) with an example. Hopefully you can figure out where I'm going with it and suit it to your needs. – egbrad Apr 15 '13 at 20:51
  • Awesome! Thank you idor_brad. Just what I needed! – Alex51482 Apr 16 '13 at 12:49
  • I realized there was a bug if you pick a different month than the current month so I fixed up the fiddle to calculate the dates a little more intuitively. Sorry about that! http://jsfiddle.net/SKqJH/11/ – egbrad Apr 16 '13 at 15:13