zoukankan      html  css  js  c++  java
  • js验证表单

    文本结构

                    <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验证

    //验证输入
            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;
            }
  • 相关阅读:
    第三周学习笔记
    质量属性
    第四周学习
    逻辑回归
    架构的概念
    第二周总结
    线性回归
    十步走-阅读笔记六
    十步走-阅读笔记五
    P2633 Count on a tree
  • 原文地址:https://www.cnblogs.com/zhuyapeng/p/10796625.html
Copyright © 2011-2022 走看看