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;
            }
  • 相关阅读:
    单片机4*4按键数码管显示0-9
    netbeans设置语言
    单片机中断的应用
    Linux 命令总结
    vc6.0快捷键大全
    怎么使PUTTY一直连接
    mysql alter 效率
    treeview
    Gitbook
    linux 进程监控软件 supervisor
  • 原文地址:https://www.cnblogs.com/zhuyapeng/p/10796625.html
Copyright © 2011-2022 走看看