Ext 自定义验证控件

    var confirm_password = new Ext.form.TextField({
        //    fieldLabel:'Confirm New Password',
            width:140,
            inputType:'password',
            allowBlank:false,
            msgTarget:'confirmpassword',
            blankText:'the value is null',
            bodyStyle: 'padding-left:5px',
            vtype:'password', //自定义验证控件的类型
            vtypeText:'two password is not equals', //错误提示
            confirmTo:'newpwd' //比较的对象ID
        });
       
        //自定义验证控件
        Ext.apply(Ext.form.VTypes,{
         password: function(val,field) {//val指这里的文本框值,field指这个文本框组件
             if(field.confirmTo) {//confirmTo是我们自定义的配置参数,一般用来保存另外的组件的id值
                 var val2 = Ext.getCmp(field.confirmTo);//根据ID取得对象
                 if(val == val2.getValue()) {
                     return true;
                 }else {
                     return false;
                 }
             }
             return true;
         }
           
        });

你可能感兴趣的:(ext)