I have two password fields and am trying to confirm they are the same before allowing the post to happen. Here is my code, it’s returning “Passwords do not match!” every time no matter what. When I do an alert(pass1) after my var pass1 = ... line, it gives me undefined. I’ve also tried var pass1 = formPanel.findField("txt_newPIN").getValue() and it returns the same thing. Here’s the code:
{
fieldLabel:"PIN/Password",
actionText:"Edit",
fieldValue:"****",
dialog:new MyAccount.DialogBox({
id:"win_editPIN",
name:"editPIN",
headerContent:"Edit Password:",
updateURL:"/uiapi/myaccount/setAccountPIN",
items:[{
id:"txt_currentPIN",
name: "currentPIN",
fieldLabel: "Current Password",
validationEvent:"blur",
allowBlank: false,
maxLength:20,
inputType:"password"
},{
id:"txt_newPIN",
name: "newPIN",
fieldLabel: "New Password",
vtype:"confirmPassword",
validationEvent:"blur",
allowBlank: false,
maxLength:20,
inputType:"password"
},{
id:"txt_confirmPIN",
fieldLabel: "Confirm Password",
vtype:"confirmPassword",
validationEvent:"blur",
initialPin:"txt_newPIN",
allowBlank: false,
maxLength:20,
inputType:"password"
}],
validateForm:function() {
var formPanel = Ext.getCmp("win_editPIN").formPanel.getForm();
// Save the fields we are going to insert values into
var pass1 = formPanel.findField("txt_newPIN");
var pass2 = formPanel.findField("txt_confirmPIN");
if (pass1 != pass2)
return {success:false, errorMessage:"Passwords do not match!"}
}
})
You need to pass field name instead of field id when use findField() method.
or simply just get its value directly