ExtJs 確認密碼驗證的實現


實現1:

*************************************************

    Ext.apply(Ext.form.VTypes, {
                confirmPwd : function(val, field) {
                    if (field.confirmPwd) {
                        var firstPwdId = field.confirmPwd.first;
                        var secondPwdId = field.confirmPwd.second;
                        this.firstField = Ext.getCmp(firstPwdId);
                        this.secondField = Ext.getCmp(secondPwdId);
                        var firstPwd = this.firstField.getValue();
                        var secondPwd = this.secondField.getValue();
                        if (firstPwd == secondPwd) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                },
                confirmPwdText : '兩次輸入的密碼不一致!'
            });

================================================

 

                    {
                        id : 'password',
                        name : 'password',
                        width : 140,
                        fieldLabel : '<font color="red">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;碼</font>',
                        // confirmPwd : {
                        // first : 'password',
                        // second : 'confirmPassword'
                        // },
                        // inputType : 'password',
                        // vtype : 'confirmPwd',
                        allowBlank : false,
                        blankText : '密碼不能為空',
                        regex : /^[\s\S]{0,20}$/,
                        regexText : '密碼長度不能超過20個字符'
                    }, {
                        id : 'confirmPassword',
                        name : 'confirmPassword',
                        width : 140,
                        fieldLabel : '<font color="red">確認密碼</font>',
                        confirmPwd : {
                            first : 'password',
                            second : 'confirmPassword'
                        },
                        // inputType : 'password',
                        vtype : 'confirmPwd',
                        allowBlank : false,
                        blankText : '確認密碼不能為空',
                        regex : /^[\s\S]{0,20}$/,
                        regexText : '確認密碼長度不能超過20個字符'
                    }

 

-----------------------------------------------------------------------------------------------------

 

實現2:

*************************************************


    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 : '兩次輸入的密碼不一致!'
            });

=================================================

 

                        {
                            id : 'newPwd',
                            name : 'newPwd',
                            width : 140,
                            inputType : 'password',
                            fieldLabel : '<font color="red">新 密 碼</font>',
                            allowBlank : false,
                            blankText : '新密碼不能為空',
                            regex : /^[\s\S]{0,12}$/,
                            regexText : '新密碼長度不能超過12個字符'
                        }, {
                            name : 'confirmPwd',
                            width : 140,
                            inputType : 'password',
                            fieldLabel : '<font color="red">確認密碼</font>',
                            vtype : 'password',
                            initialPassField : 'newPwd',
                            allowBlank : false,
                            blankText : '確認密碼不能為空',
                            regex : /^[\s\S]{0,12}$/,
                            regexText : '舊密碼長度不能超過12個字符'
                        }

 

=================================================

 

相關閱讀:

ExtJs 確認密碼驗證的兩種實現
http://taink.iteye.com/blog/618214

ExtJS中表單驗證使用自定義vtype示例
http://www.cnblogs.com/buzz/archive/2009/03/31/1425794.html

Ext JS 中實現自定義驗證 密碼修改 確認密碼
http://floger.iteye.com/blog/599614

Ext JS 中實現自定義驗證 密碼修改 確認密碼
http://blog.csdn.net/ttgzs/article/details/4239025

Extjs用戶注冊界面設計,包括密碼,郵箱等匹配和驗證
http://hi.baidu.com/pekdou/item/108039cc978b4fccef183b78


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM