【问题标题】:hide all the date before the selected date隐藏所选日期之前的所有日期
【发布时间】:2015-01-08 06:46:28
【问题描述】:

我对 jquery 很陌生。我做了两个jquery日历。一个是出发日历,另一个是到达日历。当用户在第一个日历(出发)中选择日期时,下一个日历应隐藏出发日期之前的所有日期。示例:如果用户在出发日历中选择 1 月 13 日,则到达日历应自动隐藏 1 月 13 日之前的所有日期。我该如何实现这一点。我的日历代码如下。

 jQuery("#datepickerarr").datepicker({
            dateFormat: 'dd/mm/yy',
            showOn: "both",
            buttonImage: "images/calendar.png",
            buttonImageOnly: true,
            minDate:0,
            maxDate: '+3M',
            numberOfMonths:2,
            buttonText:"click here to expand the calendar"
        });
        jQuery("#datepickerdepone").datepicker({
            dateFormat: 'dd/mm/yy',
            showOn: "both",
            buttonImage: "images/calendar.png",
            buttonImageOnly: true,
            minDate:0,
            maxDate: '+3M',
            numberOfMonths:2,

             buttonText:"click here to expand the calendar",

        });

【问题讨论】:

  • 您需要使用类似 jQuery("#datepickerarr").datepicker().minDate: new Date(2015, 1, 13) ;该日期将被选择的日期。

标签: javascript jquery html datepicker


【解决方案1】:

您可以在 onClose 出发日期选择弹出窗口的出发脚本中使用 minDate

onClose: function( selectedDate ) {
$( "#datepickerarr" ).datepicker( "option", "minDate", selectedDate );
}

见: http://jqueryui.com/datepicker/#date-range

【讨论】:

    【解决方案2】:

    在选择出发日期选择器时,您可以添加:

    onSelect: function (dateText, inst) {
                    jQuery("#datepickerdepone").datepicker('option', "minDate", dateText); 
                }
    

    Here JSFiddle for the same

    但您需要检查用户更改出发日期的另一种情况

    【讨论】:

      猜你喜欢
      • 2018-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多