2011-05-05 109 views
0

如何檢查ExtJS中的密碼強度Iam設計一個帶有舊密碼,新密碼和confirmpassword的窗口。 那麼如何diplay新密碼旁邊的密碼強度,並密碼匹配消息旁邊確認pasword(在不匹配的密碼的情況下)ExtJs密碼強度檢查程序

在此先感謝

回答

1

在我的項目中,我使用的是passwordmeter。它用來評估密碼的算法非常合乎邏輯且功能強大(但情況並非總是如此)。我把它放在箱子容器裏,放到一個formpanel中。這裏是我的代碼:

{ 

      xtype: 'box', 

      isFormField: true, 

      autoEl: { 

       tag: 'div', 

       id: 'scorebarBorder', 

       children: [{ 

        tag: 'div', 

        id: 'score', 

        html: '0%' 

       }, { 

        tag: 'div', 

        id: 'scorebar', 

        html: ' ' 

       }, { 

        tag: 'div', 

        id: 'complexity', 

        html: 'Too Short' 

       }] 

      } 

     } 

您必須向密碼字段與KEYUP事件連接到使用:

{ 

      xtype: 'textfield', 

      inputType: 'password', 

      fieldLabel: "Enter your new password", 

      minLengthText: 'Type at least 4 characters', 


      maxLengthText: 'Type maximum 50 characters', 

      enableKeyEvents: true, 

      listeners: { 

       keyup: function (field, event) { 

        chkPass(field.getRawValue()); 

       } 

      } 

     } 

你也可以使用一個V型比較兩個直通值

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: 'The passwords entered do not match!<br/>Please Re-Type' 

    }); 

}, this); 

,然後:通過用戶輸入

{

 xtype: 'textfield', 

     fieldLabel: "Please re-type your new password", 

     inputType: 'password', 


     vtype: 'password', 

     initialPassField: 'firstPassword' 

    } 

檢查也是這個site其他合格檢查的替代品。