2

I have a datepicker which I am using to set appointments. The only problem with this is that the boss wants the appointment date to only be up to the next 5 business days. I know how to disable the weekends, but I am a little unclear as to how I can make it so that if I choose a wednesday, it lets me select a date up to the next wednesday and accounts for the weekends as well. Any one have any ideas on how to accomplish this?

jeffro25
  • 145
  • 2
  • 10
  • This could help, it has a solved jsFiddle with exactly the same question as yours : http://stackoverflow.com/questions/10584701/jquery-ui-datepicker-restricted-selection-working-days – rusln Jun 25 '13 at 21:38

3 Answers3

5

I think this is what you want

$('yourSelector').datepicker({
    minDate: 0, // your min date
    maxDate: '+1w', // one week will always be 5 business day - not sure if you are including current day
    beforeShowDay: $.datepicker.noWeekends // disable weekends
});

http://jsfiddle.net/wANFJ/

wirey00
  • 33,517
  • 7
  • 54
  • 65
0

5 business days is the same as 1 full week, so please try to set the datepicker maxDate to "+1w" or "+5d".

Racso
  • 2,310
  • 1
  • 18
  • 23
-2

Check out http://api.jqueryui.com/datepicker/#option-maxDate

Can probably get away with

$( ".selector" ).datepicker({ maxDate: 5 });

EDIT: Missed the part about business days only, this obviously won't do that.

You can try the below snippet, might take into account your weekend settings.

$( ".selector" ).datepicker({ maxDate: '+1w' });
Jack
  • 8,851
  • 3
  • 21
  • 26