layui文件上传前进行表单验证

   <button type="submit" lay-submit="" lay-filter="BeforeUpload" class="layui-btn">
                    <i class="layui-icon"></i>上传
                </button>
                <button type="button" class="layui-btn" style="display:none" id="Upload">
                    <i class="layui-icon"></i>上传
                </button>

  隐藏真正的上传按钮,用一个submit类型的按钮替代上传按钮,然后进行表单验证

            form.on('submit(BeforeUpload)', function (data) {
                 //表单验证
                $("#Upload").click();
                return false;
            });        

  

posted @ 2023-02-20 18:37  奇迹之耀  阅读(397)  评论(0编辑  收藏  举报