jquery datepicker 限制时间

jquery中的datepicker插件如何屏蔽周末的时候不让选

5个回答

也是可以的,不过人的没有‘’号,不知道你的maxDate:+10D算不算周末?如果算周末的话,下面就可以了

[code="html"]<!DOCTYPE html>




<br> $(document).ready(function() {<br> $(&quot;#datepicker&quot;).datepicker({<br> beforeShowDay: $.datepicker.noWeekends,<br> minDate: &#39;+1&#39;,<br> maxDate: &#39;+10D&#39;<br> });<br> });<br>


[/code]

jquery datepicker的周六日禁用功能 找了找没有找到
不过我们以前用过my97的 有这个功能 相当不错 可以考虑一下

[url]http://www.my97.net/dp/demo/index.htm[/url]

[b]
There is the beforeShowDay option, which takes a function to be called for each date, returning true if the date is allowed or false if it is not. From the docs:
[/b]
[code="js"]
/* create an array of days which need to be disabled */
var disabledDays = ["2-21-2010","2-24-2010","2-27-2010","2-28-2010","3-3-2010","3-17-2010","4-2-2010","4-3-2010","4-4-2010","4-5-2010"];

/* utility functions */
function nationalDays(date) {
var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
//console.log('Checking (raw): ' + m + '-' + d + '-' + y);
for (i = 0; i < disabledDays.length; i++) {
if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1 || new Date() > date) {
//console.log('bad: ' + (m+1) + '-' + d + '-' + y + ' / ' + disabledDays[i]);
return [false];
}
}
//console.log('good: ' + (m+1) + '-' + d + '-' + y);
return [true];
}
function noWeekendsOrHolidays(date) {
var noWeekend = jQuery.datepicker.noWeekends(date);
return noWeekend[0] ? nationalDays(date) : noWeekend;
}

/* create datepicker */
jQuery(document).ready(function() {
jQuery('#date').datepicker({
minDate: new Date(2010, 0, 1),
maxDate: new Date(2010, 5, 31),
dateFormat: 'DD, MM, d, yy',
constrainInput: true,
beforeShowDay: noWeekendsOrHolidays
});
});

[/code]

只要这样设置一下就可以了

[code="java"]$(".date").datepicker({ [b]beforeShowDay: $.datepicker.noWeekends[/b] });[/code]

只要这样设置一下就可以了。。。上面是多打了[b][/b]
[code="js"]$(".date").datepicker({ beforeShowDay: $.datepicker.noWeekends });[/code]

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!