有没有允许在下面发现的引导日期选择器中只允许工作日选择?
https://github.com/eternicode/bootstrap-datepicker/
https://github.com/eternicode/bootstrap-datepicker/
我正在实例化日期选择器,如下所示:
$('#datepicker').datepicker(); /* Update datepicker plugin so that MM/DD/YYYY format is used. */ $.extend($.fn.datepicker.defaults,{ parse: function (string) { var matches; if ((matches = string.match(/^(\d{2,2})\/(\d{2,2})\/(\d{4,4})$/))) { return new Date(matches[3],matches[1] - 1,matches[2]); } else { return null; } },format: function (date) { var month = (date.getMonth() + 1).toString(),dom = date.getDate().toString(); if (month.length === 1) { month = "0" + month; } if (dom.length === 1) { dom = "0" + dom; } return month + "/" + dom + "/" + date.getFullYear(); } });
感谢任何帮助.
解决方法
https://github.com/eternicode/bootstrap-datepicker的最新版本已经有一个选项来禁用特定工作日的选择.从
the docs:
daysOfWeekDisabled
String,Array. Default: ‘’,[]
Days of the week that should be disabled. Values are 0 (Sunday) to 6 (Saturday). Multiple values should be comma-separated. Example: disable weekends:
'0,6'
or[0,6]
.
换句话说,只需要像这样实例化你的datepicker:
$('#datepicker').datepicker({ daysOfWeekDisabled: [0,6] });
这是一个jsfiddle演示:http://jsfiddle.net/vj77M/1/