0
我正在使用Materialise的自定義Pickadate datepicker。如何限制第二日期選擇器不超過第一日期選擇器的選定日期?
這是我的HTML,我使用Materialise的CSS
<div class="col s12 m6">
<input type="date" id="check_in" class="datepicker1">
<label for="Check-in">Check in date</label>
</div>
<div class="col s12 m6">
<input type="date" id="check_out" class="datepicker2">
<label for="check_out">Check out date</label>
</div>
這裏是我的javascript。
<script type="text/javascript">
$('.datepicker1').pickadate({
selectMonths: true, // Creates a dropdown to control month
selectYears: 1, // Creates a dropdown of 15 years to control year
min: true,
format: 'yyyy, mmmm d'
});
$('.datepicker2').pickadate({
selectMonths: true, // Creates a dropdown to control month
selectYears: 1, // Creates a dropdown of 15 years to control year
min: true,
format: 'yyyy, mmmm d'
});
</script>
Materialise公司的日期選擇器是一種改性pickadate.js。如果你檢查插件的文檔,有'min'和'max'選項:http://amsul.ca/pickadate.js/date/#limits你需要編碼一下,以便每次重新初始化第二個datepicker第一次更改爲「min」選項。 – yuriy636