0

これが私のjQueryカレンダーコードです

$(document).ready(function(){
    $( "#fromDate" ).datepicker({
          dateFormat: 'mm-dd-yy',
          changeMonth:true,
          changeYear:true,
          showOn: "button",
          buttonImage: "../../images/calendar.gif",
          buttonImageOnly: true,
          maxDate: '0',
          onSelect: function(dateText, inst)
          {$("#toDate").val('');
              $("#toDate").datepicker("option", "minDate", dateText);
          }

        });

      $( "#toDate" ).datepicker({
          dateFormat: 'mm-dd-yy',
          changeMonth:true,
          changeYear:true,
          showOn: "button",
          maxDate: '0',
          buttonImage: "../../images/calendar.gif",
          buttonImageOnly: true
        });
});
</script>

許可された日数が次の日数を#toDate超えないようにする必要があります。#fromDate + 30

どうやってやるの ?

どちらのカレンダーでも、現在の日付以外の日付を選択できないことに注意してください。

4

1 に答える 1

0

日付ピッカーには、minDate と maxDate のプロパティがあります。したがって、必要な日付でこれらのプロパティを設定できます。以下はサンプルです。

var currentDate= new Date(); 
var maxdate = new Date(currentDate); 
maxdate.setDate(currentDate.getDate() + 30); 
$("#toDate").datepicker({ 
changeMonth: true, 
changeYear: true, minDate: 
currentDate, maxDate:maxdate 
    }).datepicker('setDate',currentDate);

参照: http://jsfiddle.net/2y67W/最大日付の設定 jquery datepicker

于 2013-09-26T04:40:47.307 に答える