PDA

View Full Version : compare password1 = password2



Stephan123
2 Oct 2009, 2:10 AM
Hello !

I have a simple login - form.
In this form there are 2 textfields with inputeType 'password'.
I look for an vtypes which compare password1 with password2.
When the values are not equal then call a function.

Is there an ready vtypes aviable ?

Your sincerly

Stephan

Condor
2 Oct 2009, 3:29 AM
You can find a password vtype in the examples/form/adv-vtypes.js file.

I modified it a bit:

Ext.apply(Ext.form.VTypes, {
password : function(val, field) {
if (field.initialPassField) {
var pwd = field.ownerCt.getComponent(field.initialPassField);
var b = val == pwd.getValue();
if(b){
pwd.validate.defer(10, pwd);
}
return b;
}
return true;
},
passwordText : 'Passwords do not match'
});
Usage:

[{
xtype: 'textfield',
fieldLabel: 'Password',
name: 'password',
itemId: 'password',
vtype: 'password',
initialPassField: 'repeatPassword'
},{
xtype: 'textfield',
fieldLabel: 'Repeat password',
name: 'repeatPassword',
itemId: 'repeatPassword',
vtype: 'password',
initialPassField: 'password'
}]

Stephan123
2 Oct 2009, 3:31 AM
Hello !

The first way.
I have build an help function.
This function is called by an listener


function passwort1passwort2(){
var test1 = Ext.getCmp('myForm').getForm().items.items[9].getValue();
var test2 = Ext.getCmp('myForm').getForm().items.items[10].getValue();

if(test1.length > 0 && test2.length > 0){
if(test1 != test2){
HilfeFenster('Passwort 1 ist ungleich Passwort 2 !');
Ext.getCmp('myForm').getForm().items.items[9].setValue('');
Ext.getCmp('myForm').getForm().items.items[10].setValue('');
}
}
}

Your sincerly

Stephan