问题描述
jquery中的datepicker插件如何屏蔽周末的时候不让选 问题补充:yutian2211 写道
解决方案
也是可以的,不过人的没有‘’号,不知道你的maxDate:+10D算不算周末?如果算周末的话,下面就可以了<!DOCTYPE html><html><head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> $(document).ready(function() { $("#datepicker").datepicker({beforeShowDay: $.datepicker.noWeekends, minDate: '+1', maxDate: '+10D'}); }); </script></head><body style="font-size:62.5%;"> <div type="text" id="datepicker"></div></body></html>
解决方案二:
只要这样设置一下就可以了。。。上面是多打了[b][/b]$(".date").datepicker({ beforeShowDay: $.datepicker.noWeekends });
解决方案三:
只要这样设置一下就可以了$(".date").datepicker({ [b]beforeShowDay: $.datepicker.noWeekends[/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:/* 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 });});
解决方案五:
jquery datepicker的周六日禁用功能 找了找没有找到 不过我们以前用过my97的 有这个功能 相当不错 可以考虑一下http://www.my97.net/dp/demo/index.htm<input id="d441" type="text" class="Wdate" onFocus="WdatePicker({disabledDays:[6]})"/>