1 Star 2 Fork 0

zxj/Be-Valid

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 3.32 KB
一键复制 编辑 原始数据 按行查看 历史
zhangxingju 提交于 2024-09-05 11:51 . 校验组件开发
<!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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhang_xing_ju/be-valid.git
[email protected]:zhang_xing_ju/be-valid.git
zhang_xing_ju
be-valid
Be-Valid
master

搜索帮助