用jQuery和easyui实现登录验证的小功能

这里面都包含了easyui的布局样式,验证框,form表单等。
实现了重置密码的验证,密码长度的验证,用不明不能为空的验证和提交是否验证通过等小功能。

    <script type="text/javascript">
        $(function(){
            $.extend($.fn.validatebox.defaults.rules, {
                equals: {
                    validator: function(value,param){
                        if(value == $(param[0]).val()){
                            return true;
                        }else{
                            return false;
                        }
                    },
                    message:'请和密码相同。'
                }
            });
            $.extend($.fn.validatebox.defaults.rules, {
                panduan: {
                    validator: function(value){
                        if(value.length >= 6 && value.length<= 16){
                            return true;
                        }else{
                            return false;
                        }
                    },
                    message: '密码不能少于6位和大于16位。'
                }
            });
        $("#btn1").click(function() {
             $("#ff").form("submit",{
                    url: 'lianxi.jsp',
                    onSubmit: function(){
                        var isValid = $(this).form('validate');
                        if (!isValid){
                            $.messager.progress('close');  // hide progress bar while the form is invalid
                        }
                        return isValid; // return false will stop the form submission
                    },
                    success: function(){
                        location.href="lianxi.jsp";
                    }
                }); 
            });
        });
    </script>
    <style>
        h1{
            text-align:center;
            font-fimaly:"华文琥珀";
            color:#ffcccc;
        }
        p{
            text-align:center;
            font-fimaly:"华文琥珀";
            font-size:12px;
        }
    </style>

  </head>

  <body>
    <div style="margin:20px 0;" ></div>
    <div class="easyui-layout" style="width:auto;height:95%;">
        <div data-options="region:'north'" style="height:80px;">
            <h1>Sun公司简介</h1>
        </div>
        <div data-options="region:'south'" style="height:80px;">
            <p>Jquery EasyUI中文网内容基于EasyUI官网,由EasyUI中文小组翻译整理,完全遵循官方Free - Non-commercial 及CC BY 3.0协议。</p>
            <p>Copyright © 2014 - 2015 Jquery EasyUI中文网, 粤ICP备14024044号-2, All Rights Reserved.</p>
        </div>
        <div data-options="region:'center',title:'主要内容',iconCls:'icon-ok'">
            <form id="ff" action="lianxi.jsp">
                <table align="center">
                    <tr>
                        <td>用户名:</td>
                        <td><input id="name" class="easyui-validatebox" type="text" name="name"
                            data-options="required:true" /></td>
                    </tr>
                    <tr>
                        <td>密码:</td>
                        <td><input id="pwd" class="easyui-validatebox" type="passdord" name="pwd"
                            validType='panduan' /></td>
                    </tr>
                    <tr>
                        <td>重置密码:</td>
                        <td><input id="rpwd" class="easyui-validatebox" type="passdord" name="rpwd"
                            validType="equals['#pwd']" /></td>
                    </tr>
                    <tr>
                        <td><input id="btn1" type="submit" value="登录"></td>
                        <td><input id="btn2" type="button" value="取消"></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</body>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值