EXTjs 密码验证

来源:互联网 发布:彩虹六号数据统计 编辑:程序博客网 时间:2024/05/16 13:02
Ext.apply(Ext.form.VTypes,{   password:function(val,field){////val指这里的文本框值,field指这个文本框组件      if(field.confirmTo){//confirmTo是我们自定义的配置参数,一般用来保存另外的组件的id值       var pwd=Ext.get(field.confirmTo);//取得confirmTo指向组件ID的值         return (val==pwd.getValue());         }              return true;      }  //passwordText : 'Passwords do not match'});Ext.onReady(function(){Ext.QuickTips.init();Ext.form.Field.prototype.msgTarget='side';var panel=new Ext.FormPanel({ title:'password verification', frame:true, width:300, labelWidth:100, defaults:{  width:150  //inputType:'password'  },   defaultType: 'textfield',  items:[{    xtype:'textfield',     fieldLabel : "姓名",        name : "author_nam",        regex : /[\u4e00-\u9fa5]/,     //正则表达式在/...../之间. [\u4e00-\u9fa5] : 只能输入中文.        regexText:"只能输入中文!",         //正则表达式错误提示        allowBlank : false                //此验证依然有效.不许为空.    },{    fieldLabel:'密码',    id:"pass1",    inputType:'password'},{    fieldLabel:'确认密码',    id:"pass2",    inputType:'password',    vtype:"password",    vtypeText:"密码不一致",    confirmTo:"pass1"    }]      })  panel.render("password");  })