文本結構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;
}