问题
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?
回答1:
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/
回答2:
5 business days is the same as 1 full week, so please try to set the datepicker maxDate to "+1w" or "+5d".
回答3:
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' });
来源:https://stackoverflow.com/questions/17307865/allow-only-the-next-5-business-days-jquery-datepicker