代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>示例</title>
<style>
.layui-row {
margin: 20px;
}
</style>
<!-- 引入 layui.css -->
<link href="./layui/css/layui.css" rel="stylesheet">
</head>
<body>
<form class="layui-form">
<div class="layui-row">
<div class="layui-col-md2">
<label class="layui-form-label">身份证号码</label>
</div>
<div class="layui-col-md4">
<input id="username" type="text" name="username" lay-verify="required|iDCard" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
<div class="layui-col-md2">
<label class="layui-form-label">社会信用代码</label>
</div>
<div class="layui-col-md4">
<input type="text" name="username" lay-verify="required|creditCode" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-row">
<div class="layui-col-md2">
<label class="layui-form-label">邮箱</label>
</div>
<div class="layui-col-md4">
<input type="text" name="username" lay-verify="required|email" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
<div class="layui-col-md2">
<label class="layui-form-label">手机号</label>
</div>
<div class="layui-col-md4">
<input type="text" name="username" lay-verify="required|mobilePhone" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-row">
<div class="layui-col-md2">
<label class="layui-form-label">座机号</label>
</div>
<div class="layui-col-md4">
<input type="text" name="username" lay-verify="required|phone" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
<div class="layui-col-md2">
<label class="layui-form-label">网址</label>
</div>
<div class="layui-col-md4">
<input type="text" name="username" lay-verify="required|url" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-row">
<div class="layui-col-md2">
<label class="layui-form-label">数字</label>
</div>
<div class="layui-col-md4">
<input type="text" name="username" lay-verify="required|number" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-row">
<button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
</div>
</form>
<!-- 引入 layui.js -->
<script src="./layui/layui.js"></script>
<script src="./be-validation/validation.js"></script>
<script>
layui.use(['form', 'beValid', 'jquery'], function () {
let form = layui.form;
let $ = layui.jquery;
let beValid = layui.beValid;
beValid.verify();//{}中可自定义,参考leyui自定义规则
// 提交事件
form.on('submit(demo1)', function (data) {
let field = data.field; // 获取表单字段值
// 此处可执行 Ajax 等操作
return false; // 阻止默认 form 跳转
});
});
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。