jquery ui中月份和年份选择器中的范围选择器

jquery ui中月份和年份选择器中的范围选择器,jquery,asp.net,vb.net,Jquery,Asp.net,Vb.net,我有两个使用jquery-UI的月和年选择器的文本框。这两个文本框都很好用。现在我想,如果用户在fromtextbox中选择某个月,那么totextbox的mindatemonth应该是用户在fromtextbox中选择的月份。我如何实现这一点。 这是我用来显示月份和年份选择器的代码 $("#<%=frm_txtdatefrm.ClientID %>").datepicker({ changeMonth: true,

我有两个使用jquery-UI的月和年选择器的文本框。这两个文本框都很好用。现在我想,如果用户在fromtextbox中选择某个月,那么totextbox的mindatemonth应该是用户在fromtextbox中选择的月份。我如何实现这一点。 这是我用来显示月份和年份选择器的代码

            $("#<%=frm_txtdatefrm.ClientID %>").datepicker({
            changeMonth: true,
            changeYear: true,
            showButtonPanel: true,
            dateFormat: 'M yy'
        }).focus(function () {
            var thisCalendar = $(this);
            $('.ui-datepicker-calendar').detach();
            $('.ui-datepicker-close').click(function () {
                var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                thisCalendar.datepicker('setDate', new Date(year, month, 1));
            });
        });

        $("#<%=frm_txtdateto.ClientID %>").datepicker({
            changeMonth: true,
            changeYear: true,
            showButtonPanel: true,
            dateFormat: 'M yy'
        }).focus(function () {
            var thisCalendar = $(this);
            $('.ui-datepicker-calendar').detach();
            $('.ui-datepicker-close').click(function () {
                var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                thisCalendar.datepicker('setDate', new Date(year, month, 1));
            });
        });

下面是一个在屏幕上选择日期范围的示例

为添加函数并为选项设置值

下面是示例中的代码:

$(function() {
    $( "#from" ).datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        numberOfMonths: 3,
        onClose: function( selectedDate ) {
            $( "#to" ).datepicker( "option", "minDate", selectedDate );
        }
    });
    $( "#to" ).datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        numberOfMonths: 3,
        onClose: function( selectedDate ) {
            $( "#from" ).datepicker( "option", "maxDate", selectedDate );
        }
    });
});