0 0

jquery datepicker 限制时间15

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

问题补充:
yutian2211 写道
只要这样设置一下就可以了。。。上面是多打了[b][/b]
$(".date").datepicker({ beforeShowDay: $.datepicker.noWeekends });



这个会与$(".date").datepicker({ minDate: +1, maxDate: +10D});起冲突,两者只能显示一个,但是我想让他们并存

问题补充:
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>


+10D不包括周末
2011年5月12日 16:18

5个答案 按时间排序 按投票排序

0 0

采纳的答案

也是可以的,不过人的没有‘’号,不知道你的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>

2011年5月16日 21:58
0 0

只要这样设置一下就可以了。。。上面是多打了[b][/b]

$(".date").datepicker({ beforeShowDay: $.datepicker.noWeekends });

2011年5月14日 20:57
0 0

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

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

2011年5月14日 20:56
0 0


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
  });
});

2011年5月12日 18:17
0 0

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

http://www.my97.net/dp/demo/index.htm

<input id="d441" type="text" class="Wdate" onFocus="WdatePicker({disabledDays:[6]})"/>

2011年5月12日 17:54

相关推荐

Global site tag (gtag.js) - Google Analytics