Time format input box in Layui:
html code:
<div class="layui-inline" style="width: fit-content;"> <label class="layui-form-label" style="width: fit-content;">选择日期:</label> <div class="layui-input-inline" style="width: 150px"> <input type="text" name="beginDate" id="beginDate" lay-verify="datetime" class="layui-input"> </div> -- <div class="layui-form-mid">-</div> <div class="layui-input-inline" style="width: 150px"> <input type="text" name="endDate" id="endDate" lay-verify="datetime" class="layui-input"> </div> </div>
js code:
layui.use(['layer', 'form', 'table', 'laydate'], function () { var layer = layui.layer, $ = layui.jquery, form = layui.form, laydate = layui.laydate, table = layui.table; var beginDate = laydate.render({//渲染开始时间选择 elem: '#beginDate', //通过id绑定html中插入的start type: 'datetime', max: "2099-12-31 23:59:59",//设置一个默认最大值 done: function (value, dates) { endDate.config.min = { year: dates.year, month: dates.month - 1, //关键 date: dates.date, hours: dates.hours, minutes: dates.minutes, seconds: dates.seconds }; } }); var endDate = laydate.render({//渲染结束时间选择 elem: '#endDate',//通过id绑定html中插入的end type: 'datetime', min: "1970-1-1 00:00:00",//设置min默认最小值 done: function (value, dates) { beginDate.config.max = { year: dates.year, month: dates.month - 1,//关键 date: dates.date, hours: dates.hours, minutes: dates.minutes, seconds: dates.seconds } } }); });
elem: '#endDate' binding element;
type: 'datetime' selection type:
##max: "2099-12 -31 23:59:59" Set the default maximum valuemin: "1970-1-1 00:00:00" Set the default minimum valuedone: function (value, dates) { endDate.config.min = { year: dates.year, month: dates.month - 1, //关键 date: dates.date, hours: dates.hours, minutes: dates.minutes, seconds: dates.seconds }; }
layui usage tutorial column.
The above is the detailed content of Introduction to Layui time selection box. For more information, please follow other related articles on the PHP Chinese website!