[英]How to manipulate commencement date and resumption date using JQuery Date in Laravel
在我的 Laravel-5.8 應用程序中,我使用 jQuery-1.12.4 作為我的日期選擇器
我有休假開始日期和休假恢復日期
<div class="col-sm-4">
<div class="form-group">
<label>Commencement Date:<span style="color:red;">*</span></label>
<input type="text" id="commencement_date" class="form-control" placeholder="dd/mm/yyyy" name="commencement_date" value="{{old('commencement_date')}}" >
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Resumption Date:<span style="color:red;">*</span></label>
<input type="text" id="resumption_date" class="form-control" placeholder="dd/mm/yyyy" name="resumption_date" value="{{old('resumption_date')}}" >
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$(function () {
$('#commencement_date').datepicker({
dateFormat: 'dd-mm-yy',
});
$('#resumption_date').datepicker({
dateFormat: 'dd-mm-yy',
});
});
});
</script>
我如何制作:
開始日期中的最短日期為當天,最長。 日期為一年中的最后一天
恢復日期中的最小日期為當天 + 1(在當天添加一天)和最大。 日期為一年中的最后一天
謝謝
您可以使用 JS Date
方法,並添加一天。 然后使用minDate和MaxDate在 datePicker 中附加
var commencementDate = new Date();
var resumptionDate = new Date();
// add a day to the Resumption Date
resumptionDate.setDate(resumptionDate.getDate() + 1);
$('#commencement_date').datepicker({
dateFormat: 'dd-mm-yy',
minDate: commencementDate,
maxDate: new Date(year, 11, 31)
});
$('#resumption_date').datepicker({
dateFormat: 'dd-mm-yy',
minDate: resumptionDate ,
maxDate: new Date(year, 11, 31)
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.