您现在的位置是:网站首页 > 心得笔记

laydate 限制结束日期不能大于起始日期

盛悦2019-09-1740人围观
简介laydate 限制结束日期不能大于起始日期

var endDate= laydate.render({
            elem: '#reportTimeEnd',//选择器结束时间
            type: 'date',
            min:"1970-1-1",//设置min默认最小值
            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
                }
            }
        });
        
        var startDate=laydate.render({
            elem: '#reportTimeStrat',
            type: 'date',
            max:"2099-12-31",//设置一个默认最大值
            done: function(value, date){
                endDate.config.min ={
                    year:date.year,
                    month:date.month-1, 
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                };
            }
        });