zoukankan      html  css  js  c++  java
  • laydate 限制结束日期不能大于起始日期

    时间选择器在选择的时候,同时配置了另一个时间选择器内的参数

      <div class="form-group">
         <label for="exampleInputName2">停留时间:</label>
         <input type="text"  class="form-control" name="open"  id="start_time" placeholder="点击选择开始时间" required>
      </div>
      <div class="form-group">
         <label for="exampleInputEmail2">到</label>
         <input type="text" class="form-control"  name="close" id="end_time" placeholder="点击选择结束时间" required>
      </div>
    <script src="{{asset('/js/laydate.js')}}"></script>
    
    <script>
        var startDate = laydate.render({
            elem: '#start_time',
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm:ss',
            done: function(value, date){
                endDate.config.min ={
                    year:date.year,
                    month:date.month-1,
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                };
            }
        });
        var endDate = laydate.render({
            elem: '#end_time',
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm:ss',
            done: function(value,date){
                startDate.config.max={
                    year:date.year,
                    month:date.month-1,//注意是month-1,写在date上的话你后边的日期选择不了
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                }
            }
        });
    </script>
  • 相关阅读:
    JavaScript: RegExp + replace
    JavaScript:布局
    DOM和BOM区别
    正则表达式
    a report about the history of pragrem
    web第6次作业position
    web api
    DOM Event:事件流动(Event Flow)
    FOR衍生对象
    前端的发展
  • 原文地址:https://www.cnblogs.com/niuben/p/11727158.html
Copyright © 2011-2022 走看看