文本结构ui
<div class="layui-form-item"> <label for="username" class="layui-form-label"> <span class="x-red">*</span>类型 </label> <div class="layui-input-inline"> <select name="Type" id="Type" lay-filter="Type"> <option value="1">模板</option> <option value="2">题库</option> <option value="3">方案</option> </select> </div> </div>
js验证this
//验证输入
function verify() {
//空的验证:获取所有input标签
var inputs = $("#form").find("input[type='text']");
var bo = true;
inputs.each(function (i) {
if ($(this).attr("required")) {
if (!$(this).val().trim()) {
$(this).focus();
$(this).get(0).scrollIntoView({ block: 'center', behavior: 'smooth' });
layer.msg('输入框不能为空', {
icon: 7,
time: 2000
});
bo = false;
return false;
}
}
});
if (!bo) return bo;
var reg = /^\d*$/;
if (!reg.test($("#SortId").val()))
{
$("#SortId").focus();
$("#SortId").get(0).scrollIntoView({ block: 'center', behavior: 'smooth' });
layer.msg('排序只能为数字', {
icon: 7,
time: 2000
});
bo = false;
}
return bo;
}