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?
            Asked
            
        
        
            Active
            
        
            Viewed 9,877 times
        
    2
            
            
        - 
                    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 Answers
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
});
        wirey00
        
- 33,517
 - 7
 - 54
 - 65
 
- 
                    
 - 
                    This is perfect! Exactly what I needed! Thanks for the help! I was unaware you could use almost a php strtotime type string. Thanks again! – jeffro25 Jun 26 '13 at 13:21
 
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
 
- 
                    Specially when you are new and trying to understand how to do things correctly :/ – Racso Jun 25 '13 at 21:45
 - 
                    Late to the party, but it's because +1w or +5d would not give you business days as it'd include weekend days. – James Kemp Oct 24 '15 at 15:09
 
-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