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();
 }

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值