使用ext的Vtype密码验证错误

网站需要两次密码验证,vtype当然是最方便的方法但是只有一个页面的验证正确,代码如下:

/*
    *密码修改
    *resetpwdWin 密码显示框
    *resetpwdForm 密码修改form
    */
    
    var resetpwdForm = new Ext.form.FormPanel({
        labelAlign:'left',
        labelWidth:60,
        width:260,
        border:false,
        bodyStyle:'top:15px;left:20px',
        defaultType:'textfield',
        items:[{
            fieldLabel : '新密码',
            inputType : 'password',
            width : 120,
            itemId : 'pwd',
            allowBlank : false,
            name : 'pwd',
            id:'pwd',
            minLength : 5,
            msgTarget:'side',
            maxLength : 32,
            blankText:'输入密码只能在5-32字符之间'
        },{
            fieldLabel : '确认密码',
            inputType : 'password',
            width : 120,
            itemId : 'pwd2',
            allowBlank : false,
            name : 'pwd2',
            msgTarget:'side',
            vtype:'password',
            confirmTo:'pwd',
            vtypeText:'两次密码不一致',
            blankText:'确认密码项不能为空'
        }]
    })
    //添加自定义函数
    
    var resetpwdWin = new Ext.Window({
        width:260,
        height:150,
        title:'密码修改',
        closeAction:'hide',
        buttonAlign:'center',
        layout:'fit',
        bodyStyle:'background-color:#fff;',
        items:resetpwdForm,
        buttons:[{
            text:'保存修改',
            handler:function(){
                if(resetpwdForm.getForm().isValid()){
                    Ext.Ajax.request({
                        url:'user!updatePwd.action',
                        params:{
                            'newPassword':resetpwdForm.getForm().findField("pwd").getValue()
                        },
                        success:function(response){
                            var newJson=Ext.decode(response.responseText);
                            if(newJson.success){
                                Ext.MessageBox.show({title:'提示',msg:'密码修改成功'});
                            }else{
                                Ext.MessageBox.show({title:'提示',msg:'密码修改失败'});
                            }
                            resetpwdWin.hide();
                        }
                    })
                }
            }
        },{
            text:'取消',
            handler:function(){
                resetpwdWin.hide();
            }
        }]
    })

其他页面会出现

TypeError: vt[this.vtype] is not a function
if(!vt[this.vtype](value, this)){
ext-all-debug.js (第 52824 行)


这个错误,真是让我纠结,网上好像也没有人遇到过这个问题,我猜测不会是第二次使用出现的问题吧。

        根据问题的提示,应该是说vtype的类型不正确,所以我自定义了password的方法,代码如下:

/**
             * 用Ext.apply方法添加自定义的password验证函数
             */
            Ext.apply(Ext.form.VTypes,{
                password:function(val, field) { //val:这个文本框的值,field:这个文本框组件
                    if(field.confirmTo) { //confirmTo是自定义的配置参数,一般用来保存另外的组件的id值
                        var pwd = Ext.getCmp(field.confirmTo);  //取得confirmTo的那个id的值
                        return(val == pwd.getValue());
                    }
                    return false;
                }
            
            });


问题得到解决。不过我依然不知道为什么会有这个问题,不知道有谁能帮我解答?是ext的问题么?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值