1. Time selector
-> not be greater than the start date expiration date, an expiration date is less than the start date
html:
<div class="layui-inline"> <input id="startDate" class="layui-input test-item" type="text" placeholder="起始日期"/> </div> <div class="layui-inline"> <input id="endDate" class="layui-input test-item" type="text" placeholder="截止日期"/> </div>
js:
// initialization time layui.use ( 'laydate', function () { var laydate = layui.laydate; / * Lay () each (function () {// if no authentication on the size of 'test-item.'. write back is not required on the list laydate.render ({ elem: the this , Trigger: 'the Click' }); }); * / var startDate = laydate.render ({ elem: '#startDate' , type: 'DATE ' , btns: [ ' Clear ',' Confirm ' ], DONE: function (value, date){ if(value){ endDate.config.min={ year:date.year, month:date.month-1,//关键 date:date.date, hours:date.hours, minutes:date.minutes, seconds:date.seconds }; }else{ endDate.config.min=startDate.config.min; } } }); var endDate=laydate.render({ elem:'#endDate', type:'date', btns: ['clear','confirm'], done:function(value,date){ if(value){ startDate.config.max={ year:date.year, month:date.month-1,//关键 date:date.date, hours:date.hours, minutes:date.minutes, seconds:date.seconds } }else{ startDate.config.max=endDate.config.max; } } }) });