Allow only the next 5 business days jquery datepicker

时光毁灭记忆、已成空白 提交于 2019-12-11 13:17:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!