
<script src="js/md5.min.js"></script>
<div class="layui-form" lay-filter="layuiadmin-form" >
    <input type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline" style="width:400px">
            <input type="text" name="user" placeholder="请输入" maxlength="30" lay-verify="required|user" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline" style="width:400px">
            <input type="password" name="pwd" value="" maxlength="30" lay-verify="required|pwd" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-inline" style="width:400px">
            <input type="password" name="repwd" value="" maxlength="16" lay-verify="required|pwd" autocomplete="off" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-front-submit" value="保存" class="layui-btn">
        </div>
    </div>
</div>

<script>
    layui.use(['admin', 'user', 'form'], function () {
        var $ = layui.$
        , form = layui.form;
        //自定义验证
        form.verify({
            user: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (!new RegExp("^[a-zA-Z0-9_]{4,16}$").test(value)) {
                    return '用户名必须4~16位英文字母数字下划线';
                }
            },
            pwd: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (!new RegExp("^[a-zA-Z0-9_]{6,16}$").test(value)) {
                    return '密码必须6~16位英文字母数字下划线组合';
                }
            }
        });

    })
</script>