如何在Laravel中使用JQuery Date操纵开始日期和恢复日期 [英] How to manipulate commencement date and resumption date using JQuery Date in Laravel

查看:94
本文介绍了如何在Laravel中使用JQuery Date操纵开始日期和恢复日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Laravel-5.8应用程序中,我将jQuery-1.12.4用于日期选择器

In my Laravel-5.8 application, I am using jQuery-1.12.4 for my datepicker

我有休假开始日期和休假恢复日期

I have Leave Commencement Date and Leave Resumption Date

          <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. 开始日期中的最小日期为当前日期和最大日期.日期是一年中的最后一天

  1. Minimum Date in Commencement Date to be current day and Max. Date to be Last Day of the year

恢复日期中的最小日期为当前日期+ 1(向当前日期添加一天)和最大值.日期是一年中的最后一天

Minimum Date in Resumption Date to be current day + 1 (add a day to current day) and Max. Date to be Last Day of the year

谢谢

推荐答案

您可以使用JS Date方法,并添加一天.然后使用 minDate

You can use JS Date method, and add a day. Then attach within datePicker using minDate and MaxDate

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)               
});

这篇关于如何在Laravel中使用JQuery Date操纵开始日期和恢复日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆