Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui Jquery UI日期选择器组合函数_Jquery Ui_Datepicker - Fatal编程技术网

Jquery ui Jquery UI日期选择器组合函数

Jquery ui Jquery UI日期选择器组合函数,jquery-ui,datepicker,Jquery Ui,Datepicker,我使用来自jQueryUIDatePicker示例站点的脚本1。它提供了选择数据范围的能力。我添加了minDate:0行,它禁用了今天之前的所有日期。 我想把它和我在堆栈溢出中找到的函数2结合起来。它禁用日历中的日期数组 我尝试将这些脚本组合起来,但我无法使它们一起工作选择日期范围、禁用今天之前的日期和禁用日期数组。 非常感谢您的帮助 1来自jquery UI datepicker示例站点的代码。这有一个工作样本 $(function() { $( "#from" ).datepicke

我使用来自jQueryUIDatePicker示例站点的脚本1。它提供了选择数据范围的能力。我添加了minDate:0行,它禁用了今天之前的所有日期。 我想把它和我在堆栈溢出中找到的函数2结合起来。它禁用日历中的日期数组

我尝试将这些脚本组合起来,但我无法使它们一起工作选择日期范围、禁用今天之前的日期和禁用日期数组。 非常感谢您的帮助

1来自jquery UI datepicker示例站点的代码。这有一个工作样本

$(function() {
    $( "#from" ).datepicker({
      minDate: 0,
      changeMonth: true,
      numberOfMonths: 2,
      onClose: function( selectedDate ) {
        $( "#to" ).datepicker( "option", "minDate", selectedDate );
      }
    });
    $( "#to" ).datepicker({
      minDate: 0,
      changeMonth: true,
      numberOfMonths: 2,
      onClose: function( selectedDate ) {
        $( "#from" ).datepicker( "option", "maxDate", selectedDate );
      }
    });
  });


<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
</head>

<body>

<label for="from">From</label>
<input type="text" id="from" name="from">
<label for="to">to</label>
<input type="text" id="to" name="to">


</body>

只需将这些选项组合如下:

var array = ["2014-12-14","2014-12-15","2014-12-16"];

$( "#from" ).datepicker({
      minDate: 0,
      changeMonth: true,
      numberOfMonths: 2,
      beforeShowDay: function(date){
        var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
        return [ array.indexOf(string) == -1 ]
      },
      onClose: function( selectedDate ) {
          if (selectedDate) {
            $( "#to" ).datepicker( "option", "minDate", selectedDate );
          }
      }
   });
$( "#to" ).datepicker({
      minDate: 0,
      changeMonth: true,
      numberOfMonths: 2,
      beforeShowDay: function(date){
        var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
        return [ array.indexOf(string) == -1 ]
      },
      onClose: function( selectedDate ) {
          if (selectedDate) {
             $( "#from ").datepicker( "option", "maxDate", selectedDate);
          }
      }
  });

这是你想要的吗?这正是我想要的。非常感谢你。我试着像这样混合代码,但肯定忽略了一些缺乏技能的东西。
var array = ["2014-12-14","2014-12-15","2014-12-16"];

$( "#from" ).datepicker({
      minDate: 0,
      changeMonth: true,
      numberOfMonths: 2,
      beforeShowDay: function(date){
        var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
        return [ array.indexOf(string) == -1 ]
      },
      onClose: function( selectedDate ) {
          if (selectedDate) {
            $( "#to" ).datepicker( "option", "minDate", selectedDate );
          }
      }
   });
$( "#to" ).datepicker({
      minDate: 0,
      changeMonth: true,
      numberOfMonths: 2,
      beforeShowDay: function(date){
        var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
        return [ array.indexOf(string) == -1 ]
      },
      onClose: function( selectedDate ) {
          if (selectedDate) {
             $( "#from ").datepicker( "option", "maxDate", selectedDate);
          }
      }
  });