1

I am using jqueryUI datepicker for a reservation form. here's the almost intact code from datepicker with date-range

$(function() {
    var dates = $( "#from, #to" ).datepicker({
        dateFormat: 'dd-mm-yy',
        minDate: "+0D",
        defaultDate: "+0D",
        changeMonth: true,
        numberOfMonths: 1,
        onSelect: function( selectedDate ) {
            var option = this.id == "from" ? "minDate" : "maxDate",
                instance = $( this ).data( "datepicker" ),
                date = $.datepicker.parseDate(
                    instance.settings.dateFormat ||
                    $.datepicker._defaults.dateFormat,
                    selectedDate, instance.settings );
            dates.not( this ).datepicker( "option", option, date );
        }
    });
});

the way it works now: when i select a date on the first box, the minimum date on the second box is automatically set at that date.

i want it to move to the next day.

say i pick 1/1/2010 on the first box, i want the first available date on the sencond box to be 2/1/2010 (d/m/yyyy format)

i cant figure it out, any help would be greatly appreciated

4

1 に答える 1

1

変更されたコード:

$(function() {
        var dates = $( "#from, #to" ).datepicker({
            dateFormat: 'dd-mm-yy',
            minDate: "+0D",
            defaultDate: "+0D",
            changeMonth: true,
            numberOfMonths: 1,
            onSelect: function( selectedDate ) {
                var option = this.id == "from" ? "minDate" : "maxDate",
                    instance = $( this ).data( "datepicker" ),
                    date = $.datepicker.parseDate(
                        instance.settings.dateFormat ||
                        $.datepicker._defaults.dateFormat,
                        selectedDate, instance.settings );
                this.id == "from" ? date.setDate(date.getDate()+1) : date.setDate(date.getDate()-1);
                dates.not( this ).datepicker( "option", option, date );
            }
        });
    });

this.id == "from" ? date.setDate(date.getDate()+1) : date.setDate(date.getDate()-1);設定前に追加mindateまたはmaxdate

于 2012-04-04T17:31:52.070 に答える