Ext:密码验证

//自定义验证密码

Ext.apply(Ext.form.VTypes,{
password : function(val, field)
{
        if (field.initialPassField)
{
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },
    passwordText : '确认密码有误,请重新输入!'
});

 

 

/*initialPassField是自定义的属性,
Ext.apply扩展了表单的自动验证功能(VType),
如果控件中有initialPassField属性,那么验证的时候将该组件的值
与id为initialPassField所指定的值的组件 的值进行比较,不一致则提醒。*/

 

var wytUserAddForm = Ext.getCmp("wytUserAddForm");
 if (wytUserAddForm == null || wytUserAddForm == undefined) {
  var wytUserAddForm = new Ext.form.FormPanel({
     id : "wytUserAddForm",
     labelWidth : 80,
     buttonAlign : "center",
     labelAlign : "right",
     // bodyStyle : "padding:5 5 5 5",
     // bodyStyle : 'padding: 10px 10px 0 10px;',
     frame : true,
     items : [loginNameTxt, {
        fieldLabel : "登录密码",
        name : 'wytUser.password',
        id : 'pass',
        inputType : "password",
        width : 250,
        xtype : "textfield",
        allowBlank : false,
        blankText : "密码不能为空",
        maxLength : 16,
        minLength : 1,
        maxLengthText : "密码长度为1-16位.",
        minLengthText : "密码长度为1-16位."
       }, {
        fieldLabel : '确认密码',
        inputType : 'password',
        vtype : "password",
        xtype : "textfield",
        name : "temp",
        width : 250,
        allowBlank : false,
        blankText : "确认密码不能为空!",
        initialPassField : 'pass' // id of the initial
       }, {
        xtype : "textfield",
        fieldLabel : "用户昵称",
        name : "wytUser.displayName",
        width : 250,
        maxLength : 16,
        minLength : 1,
        allowBlank : false,
        blankText : "用户昵称不能为空!",
        emptyText : "请输入用户昵称!",
        minLengthText : "用户昵称字符长度为1-16位.",
        maxLengthText : "用户昵称字符长度为1-16位."
       }, cmbRole,cmbRoleLevel,new Ext.form.RadioGroup({
          fieldLabel : '用户性别',
          width : 100,
          height : 25,
          items : [{
             boxLabel : '男',
             name : 'wytUser.sex',
             checked : true,
             inputValue : 1
            }, {
             boxLabel : '女',
             name : 'wytUser.sex',
             inputValue : 2
            }]
         })],
     buttons : [{
        text : "提 交",
        handler : submit
       }, {
        text : "重 置",
        handler : reset
       }, {
        text : "关 闭",
        handler : close
       }]
    });
 }
 
 // 提交
 function submit() {
  var str = '';
  str = cmbRole.getValue()+"-"+cmbRoleLevel.getValue();
  // 判断是否通过验证
  if (wytUserAddForm.getForm().isValid()) {
   wytUserAddForm.getForm().submit({
    clientValidation : true,// 进行客户端验证
    waitMsg : "正在提交数据",
    waitTitle : "提示",
    url : Action.sys.UserMngAction.DO_ADD,
    method : "POST",
    params : {
     'json' : str
    },
    success : function(res, opt) {
     if (opt.result.success) {
      Ext.quick.msg("提示", "成功添加一条会员信息!");
      win.close();
      if (cb)
       cb(opt.result.configUrl);
     } else {
      Ext.Msg.alert("提示", "添加会员失败,errorCode:"
          + opt.result.error);
     }
    },
    failure : function() {
     Ext.Msg.alert("提示", "会员添加失败!");
    }
   });
  }
 }
 // 重置
 function reset() {
  // 重置表单
  wytUserAddForm.getForm().reset();
 }
 function close() {
  win.close();
 }

 

 

 

阅读更多

没有更多推荐了,返回首页