2020年3月27日

laydate设置开始和结束时间


html


<input type="text" class="text " name="" id="time1" value="" placeholder="选择开始时间" />

<input type="text" class="text " name="" id="time2" value="" placeholder="选择结束时间" />

 

js


var startDate = laydate.render({
    elem: "#time1"
    ,trigger: 'click'
    ,type:'datetime'
    ,done: function (value, date) {
            if (value !== '') {
                endDate.config.min.year = date.year;
                endDate.config.min.month = date.month - 1;
                endDate.config.min.date = date.date;
                endDate.config.min.hours=date.hours;
                endDate.config.min.minutes=date.minutes;

            } else {
                endDate.config.min.year = '';
                endDate.config.min.month = '';
                endDate.config.min.date = '';
                endDate.config.min.hours = '';
                endDate.config.min.minutes = '';
            }
        }
});
var endDate = laydate.render({
    elem: "#time2"
    ,trigger: 'click'
    ,type:'datetime'
    ,done: function (value, date) {
            if (value !== '') {
                startDate.config.max.year = date.year;
                startDate.config.max.month = date.month - 1;
                startDate.config.max.date = date.date;
                startDate.config.max.hours = date.date;
                startDate.config.max.minutes = date.date;
            } else {
                startDate.config.max.year = '';
                startDate.config.max.month = '';
                startDate.config.max.date = '';
                startDate.config.max.hours = '';
                startDate.config.max.minutes = '';
            }
        }
});

本文由专业的WEB前端外包公司-切图网原创,转载请保留版权( WEB前端开发外包www.qietu.com切图网始于2007年,提供高品质的前端开发服务、前端外包、切图外包。欢迎来电咨询!热线:027-81777732、13343477732