作为标题,我在项目中实现了两个 datePicker,我的目标是第二个 datePicker 不能选择在第一个 datePicker 中选择的日期之前的日期。
代码:
<div class="col-md-4">
<form name="NOME_FORM" method="post" action="registra_campagne.php" class="text-center border border-light p-5" onsubmit="return validateForm()">
<p class="h4 mb-4">Durata Campagna</p>
<div class="md-form">
<!--The "from" Date Picker -->
<input name="data_inizio" placeholder="Data inizio" type="text" id="date-picker-example" class="form-control datepicker">
<label for="date-picker-example">Inizio</label>
</div>
<div class="md-form">
<!--The "to" Date Picker -->
<input name="data_fine" placeholder="Data Fine" type="text" id="date-picker-example2" class="form-control datepicker">
<label for="date-picker-example2">Fine</label>
</div>
<input class="btn btn-info btn-block" name="submit" type="submit" value="Aggiungi"><br>
</form>
</div>
<script type="text/javascript">
// Data Picker Initialization
$('.datepicker').pickadate({
min : new Date(),
onClose: function(){
$('#date-picker-example2').pickadate({
min : $('.datepicker').val()
})
}
});
$('.datepicker').pickadate({
// Escape any “rule” characters with an exclamation mark (!).
format: 'yyyy/mm/dd',
formatSubmit: 'Y/m/d',
hiddenPrefix: 'prefix__',
hiddenSuffix: '__suffix'
})
$('.datepicker').pickadate({
closeOnSelect: false,
closeOnClear: false
});
$('#input_starttime').pickatime({
twelvehour: true
});
$('#input_endtime').pickatime({
darktheme: true,
twelvehour: false
});
</script>
我将非常感激,因为到目前为止,唯一实现的功能是使用 datePicker 的用户无法选择当前日期之前的日期