Layui中時間格式的輸入框:
html程式碼:
<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程式碼:
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' 綁定元素;
##type: 'datetime' 選擇類型:max: "2099-12 -31 23:59:59" 設定預設最大值min: "1970-1-1 00:00:00" 設定預設最小值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 }; }
layui使用教程欄位。
以上是Layui時間選擇框介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!