我正在努力解决这个问题。我还是这样做了,
$(function() {
$( "#datepicker" ).datepicker({
dateFormat: 'yy-mm-dd',
firstDay: 1,
minDate:1
});
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<input type="text" id="datepicker">
&#13;
如果您运行此代码,则可以看到日历。
我想要禁用整个当前周。可用日期将从下周开始。
例如,今天是18.07.2016
。因此,如果有人想要使用此日历,那么整整一周都将变为非活动状态。下一个可用日期将从24.07.2016
开始。
提前感谢您的帮助。
答案 0 :(得分:2)
首先查找星期几。并且将相应计算,并且将禁用当前周的所有日期。请参考以下代码。
x = 100 # line at this x position
y0 = 0 # y limits of a line
y1 = 100
plt.plot((x,x),(y0,y1),'k--')
答案 1 :(得分:0)
禁用从星期日到星期六的当前星期,您只需将firstDay
设置为0(星期日)并使用beforeShowDay
用于将日期作为参数并返回数组。参考阅读Datepicker Option - beforeShowDay
请检查代码段以启用过去和将来的所有其他日期,但禁用当前周日期除外。
从星期日到星期六禁用,请使用以下代码段
$(function() {
$("#datepicker").datepicker({
firstDay: 0,
beforeShowDay: function (date) {
var sunday = new Date();
sunday.setHours(0,0,0,0);
sunday.setDate(sunday.getDate() - (sunday.getDay() || 0));
var saturday = new Date(sunday.getTime());
saturday.setDate(sunday.getDate() + 6);
if (date >= sunday && date <= saturday) {
return [false, ''];
}
else {
return [true, ''];
}
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<input type="text" id="datepicker">
并且,也可以从星期一开始禁用整周 到星期日
$(function() {
$('#datepicker').datepicker({
firstDay: 1,
beforeShowDay: function (date) {
var monday = new Date();
monday.setHours(0,0,0,0);
monday.setDate(monday.getDate() + 1 - (monday.getDay() || 7));
var sunday = new Date(monday);
sunday.setDate(monday.getDate() + 6);
if (date >= monday && date <= sunday) {
return [false, ''];
} else {
return [true, ''];
}
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<input type="text" id="datepicker">
答案 2 :(得分:0)
这是禁用特定周的简单方法
<script>
$(function(){
$('.bet_end').datepicker({ //ere .bet_end Is A Datepicker Class Name
daysOfWeekDisabled: [0,6] //Here Type Only Column Number To Disable Week
});
});
</script>
Click here To See Image (Sunday And Saturdat All Week Are Disable)