0

を追加しようとしましdateFormat: "dd-mm-yy"たが、残りの機能が機能しません。次に、フォーマットをグローバルに変更しようとしましたが、

 $.datepicker.setDefaults({dateFormat: 'dd-mm-yy'});

しかし、それもうまくいきませんでした。jquery-1.9.1 と jquery-ui-1.10.3 を使用しています。

$(document).ready(function formUi() {
    var dateToday = new Date();
    $("#datepicker-round-trip-1").datepicker({
        numberOfMonths: 2,
        showButtonPanel: true,
        changeMonth: true,
        changeYear: true,
        inline: true,
        maxDate: new Date(new Date($('datepicker-round-trip-2').val()).valueOf()),
        beforeShow: function () {
            if ($("#datepicker-round-trip-1").val() == "" && $("#datepicker-round-trip-2").val() == "") {
                $("#datepicker-round-trip-1").datepicker('option', { minDate: dateToday, maxDate: null });
            }
            else {
              $("#datepicker-round-trip-1").datepicker('option', { minDate: dateToday });
            }
        },
        onSelect: function (dateText, inst) {
            var currentDate = new Date(dateText);
            var valueofcurrentDate = currentDate.valueOf();
            var newDate = new Date(valueofcurrentDate);
            $("#datepicker-round-trip-2").datepicker("option", "minDate", newDate);
        }
    });

    $("#datepicker-round-trip-2").datepicker({
        numberOfMonths: 2,
        showButtonPanel: true,
        changeMonth: true,
        changeYear: true,
        inline: true,
        minDate: new Date(new Date($('#datepicker-round-trip-2').val()).valueOf()),
        beforeShow: function () {
            if ($("#datepicker-round-trip-1").val() == "" && $("#datepicker-round-trip-2").val() == "") {
                $("#datepicker-round-trip-2").datepicker('option', { minDate: dateToday, maxDate: null });
            }
        },
        onSelect: function (dateText, inst) {
            var currentDate = new Date(dateText);
            var valueofcurrentDate = currentDate.valueOf();
            var newDate = new Date(valueofcurrentDate);
            $("datepicker-round-trip-1").datepicker("option", "maxDate", newDate);
        }
    });
});

このスクリプトは、日付ピッカーの minDate を、前の日付ピッカーで選択された最後の日付に設定するだけです。ヘルプやガイダンスをいただければ幸いです:)

4

1 に答える 1

0

これを試してください: http://jsfiddle.net/MXstJ/ または http://jsfiddle.net/gc4nM/

役立つリンク: http://jqueryui.com/datepicker/

これがあなたの原因に合うことを願っています:)

コード

$('#z').datepicker({
    inline: true,
    altField: '#d',
    dateFormat: 'dd-mm-yy',
    defaultDate: new Date()
});
于 2013-10-13T22:07:40.120 に答える