新版laydate设置起始时间,并根据起始时间设置结束时间最大值

<script>

//开始时间

var start = laydate.render({

elem: '#takedate',

type: 'date', //可选择:年月日

// theme: '#44acff',

min: -0, //最小日期为当前日期的前一天

max: +89,

trigger: 'click', //采用click弹出

ready: function () {

start.hint('日期可选值设定在 <br> 今日起89天内');

},

done: function (value, date, endDate) {

if(date!=''){

end.config.min = {

year: date.year,

month: date.month - 1,

date: date.date,

hours: date.hours,

minutes: date.minutes,

seconds: date.seconds

}; //开始日选好后,重置结束日的最小日期

end.config.max = {

year: date.year,

month: date.month - 1,

date: date.date + 89,

// hours: date.hours,

// minutes: date.minutes,

// seconds: date.seconds

}; //开始日选好后,重置结束日的最小日期

end.config.value = {

year: date.year,

month: date.month - 1,

date: date.date,

hours: date.hours,

minutes: date.minutes,

seconds: date.seconds

}; //将结束日的初始值设定为开始日

}

else{

end.config.min = {

year: '',

month: '',

date: '',

hours: '',

minutes: '',

seconds: ''

}; //开始日选好后,重置结束日的最小日期

end.config.btns = ['clear', 'now', 'confirm'];

}

}

});

//时间有效范围设定在: 上午八点到下午十点

var starttime = laydate.render({

elem: '#taketime',

format: 'HH:mm',

type: 'time', //可选择:时分秒

min: '08:00:00',

max: '22:00:00',

trigger: 'click' //采用click弹出

});

//结束时间

var end = laydate.render({

elem: '#stilldate',

type: 'date', //可选择:年月日时分秒

min: -0, //最小日期为当前日期的前一天

max: '2099-6-16 23:59:59',

trigger: 'click', //采用click弹出

ready: function () {

end.hint('日期可选值设定在 <br> 取车日起89天内');

},

done: function (value, date, endDate) {

if (date != '') {

// start.config.max = {

// year: date.year,

// month: date.month - 1,

// date: date.date,

// hours: date.hours,

// minutes: date.minutes,

// seconds: date.seconds

// }; //结束日选好后,重置开始日的最大日期

}

else {

start.config.max = {

year: '',

month: '',

date: '',

hours: '',

minutes: '',

seconds: ''

}; //开始日选好后,重置结束日的最小日期

start.config.btns = ['clear', 'now', 'confirm'];

}

}

});

//时间有效范围设定在: 上午八点到下午十点

var endtime = laydate.render({

elem: '#stilltime',

format: 'HH:mm',

type: 'time', //可选择:时分秒

min: '08:00:00',

max: '22:00:00',

trigger: 'click', //采用click弹出

});

</script>

猜你喜欢

转载自blog.csdn.net/weixin_42615523/article/details/81216659