更改第二个datepicker日历的minDate

时间:2015-02-08 07:24:46

标签: javascript jquery datepicker

我有一个jQuery datepicker,除了第二个日历的最短日期(Out)之外它工作正常 如何在datepicker

的“结束”日期中再添加一天

jQuery代码是 -

 // datepicker1
    tjq('.datepicker-wrap input').each(function() {
        var minDate = tjq(this).data("min-date");
        var maxDate = tjq(this).data("max-date");
        if (typeof minDate == "undefined") {
            minDate = +2;
        }
        if (typeof maxDate == "undefined") {
            maxDate = null;
        }
        tjq(this).datepicker({

            showOn: 'button',
            buttonImage: 'images/icon/blank.png',
            buttonText: '',
            buttonImageOnly: true,
            changeYear: false,
            /*showOtherMonths: true,*/
            minDate: minDate,
            dateFormat: "yy-mm-dd",
closeText: 'Inchide',
        prevText: '« Luna precedenta',
        nextText: 'Luna urmaatoare »',
        currentText: 'Azi',
        monthNames: ['Ianuarie','Februarie','Martie','Aprilie','Mai','Iunie',
        'Iulie','August','Septembrie','Octombrie','Noiembrie','Decembrie'],
        monthNamesShort: ['Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun',
        'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        dayNames: ['Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'],
        dayNamesShort: ['Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'],
        dayNamesMin: ['Du','Lu','Ma','Mi','Jo','Vi','Sa'],
        weekHeader: 'Sapt',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
            beforeShow: function(input, inst) {
                var themeClass = tjq(input).parent().attr("class").replace("datepicker-wrap", "");
                tjq('#ui-datepicker-div').attr("class", "");
                tjq('#ui-datepicker-div').addClass("ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all");
                tjq('#ui-datepicker-div').addClass(themeClass);
            },
onClose: function(selectedDate) {
                if ( tjq(this).attr('name') == 'In' ) {
                    if ( tjq(this).closest('form').find('input[name="Out"]').length > 0 ) {
                        tjq(this).closest('form').find('input[name="Out"]').datepicker("option", "minDate", selectedDate);
                    }
                }
                if ( tjq(this).attr('name') == 'Out' ) {
                    if ( tjq(this).closest('form').find('input[name="In"]').length > 0 ) {
                        tjq(this).closest('form').find('input[name="In"]').datepicker("option", "maxDate", selectedDate);
                    }
                }
            }
        });
    });

“In”的minDate必须为+1天,而“Out”必须为“In”后的+1天

由于

0 个答案:

没有答案