Extjs4.x Vtype扩展实现验证密码和确认密码相等
2013-09-14 08:04
459 查看
原创:ITeye
1.扩展Vtype
2.用法
1.扩展Vtype
//实现验证两次输入的密码一致 Ext.apply(Ext.form.VTypes, { repetition: function(val, field) { //返回true,则验证通过,否则验证失败 if (field.repetition) { //如果表单有使用repetition配置,repetition配置是一个JSON对象,该对象提供了一个名为targetCmpId的字段,该字段指定了需要进行比较的另一个组件ID。 var cmp = Ext.getCmp(field.repetition.targetCmpId); //通过targetCmpId的字段查找组件 if (Ext.isEmpty(cmp)) { //如果组件(表单)不存在,提示错误 Ext.MessageBox.show({ title: '错误', msg: '发生异常错误,指定的组件未找到', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return false; } if (val == cmp.getValue()) { //取得目标组件(表单)的值,与宿主表单的值进行比较。 return true; } else { return false; } } }, repetitionText: '两次输入的密码不一致!' })
2.用法
{ fieldLabel:'<font color="red">密码</font>', allowBlank:false, inputType:'password', name:'pwd1', id:'pwd1', regex:/^\d{6,16}$/, hideTrigger:true, xtype:'numberfield', regexText:"密码6-16位之间,且只能为数字!" }, { fieldLabel:'<font color="red">确认密码</font>', allowBlank:false, inputType:'password', name:'pwd2', id:'pwd2', regex:/^\d{6,16}$/, hideTrigger:true, xtype:'numberfield', regexText:"密码6-16位之间,且只能为数字!", vtype: 'repetition', //指定repetition验证类型 repetition: { targetCmpId: 'pwd1' } //配置repetition验证,提供目标组
相关文章推荐
- ExtJs 确认密码验证的实现
- ExtJs 确认密码验证的两种实现
- ExtJs 确认密码验证的两种实现
- Ext JS 中实现自定义验证 密码修改 确认密码
- Validator框架验证确认密码与密码是否相等
- Ext JS 中实现自定义验证 密码修改 确认密码
- ExtJS4 如何实现密码验证
- (六)SSO之CAS框架扩展 修改CAS源码实现与ESS动态密码验证对接
- Ext.js5表单—验证vtype扩展(时间段以及密码确认)(50)
- EXTJS 密码确认与验证
- jQuery扩展+xml实现表单验证功能的方法
- MVVM架构~knockoutjs系列之扩展ajax验证~验证输入数据是否与后台数据相等
- jQuery+ajax实现修改密码验证功能实例详解
- 试题:用JavaScript实现密码验证功能
- php实现表单密码验证的代码实例
- Java连接MySQL数据库实现用户名密码的验证方法 Java语句中sql查询语句'' ""作用
- java正则验证密码必填字母数字特殊字符及扩展
- java编程,通过终端实现一个用户密码验证
- ASP.NET结合JS实现密码强度的验证功能(转)
- JavaScript实现密码强度验证