标签:获得 col 关闭 表单 for false ret 表单验证 code
<input type="text" id="subject_add" name="subject_add" lay-verify="subject_add" class="layui-input">
lay-verify="subject_add"
<script>layui.use([‘form‘, ‘layer‘],
function() {
$ = layui.jquery;
var form = layui.form,
layer = layui.layer;
//自定义验证规则
form.verify({
subject_add: function(value) {
if (value.length < 5) {
return ‘科目名至少得2个字符‘;
}
},
});
//监听提交
form.on(‘submit(add)‘,
function(data) {
console.log(data);
//发异步,把数据提交给php
layer.alert("增加成功", {
icon: 6
},
function() {
// 获得frame索引
var index = parent.layer.getFrameIndex(window.name);
//关闭当前frame
parent.layer.close(index);
});
return false;
});
});</script>
标签:获得 col 关闭 表单 for false ret 表单验证 code
原文地址:https://www.cnblogs.com/linzenews/p/12786621.html