隐藏所选日期之前的所有日期

时间:2015-01-08 06:46:28

标签: javascript jquery html datepicker

我对jquery很新。我做了两个jquery日历。一个是出发,另一个是到达日历。当用户选择第一个日历(出发)中的日期时,下一个日历应该隐藏出发日期之前的所有日期。示例:如果用户在出发日历中选择Jan 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",

        });

2 个答案:

答案 0 :(得分:0)

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

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

请参阅: http://jqueryui.com/datepicker/#date-range

答案 1 :(得分:0)

选择您可以添加的离境日期选择器:

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

Here JSFiddle for the same

但您需要检查用户更改出发日期的其他方案

相关问题