【问题标题】:How to manipulate commencement date and resumption date using JQuery Date in Laravel如何在 Laravel 中使用 JQuery Date 操作开始日期和恢复日期
【发布时间】:2020-07-13 22:31:34
【问题描述】:

在我的 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. 开始日期中的最短日期为当天,最长为当天。日期为一年中的最后一天

  2. 恢复日期中的最小日期为当天 + 1(在当天添加一天)和最大。日期为一年中的最后一天

谢谢

【问题讨论】:

标签: jquery laravel


【解决方案1】:

您可以使用JS Date 方法,并添加一天。然后使用 minDateMaxDate 在 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)               
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-16
    • 1970-01-01
    • 2022-01-23
    • 2019-01-13
    • 1970-01-01
    • 2017-11-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多