Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Changing a textfield to passwordfield dynamically


The simple way to use setAttribute(), like:

{
xtype: 'button',
name: 'p_acc_pass',
id: 'p_acc_pass',
enableToggle : true,
fieldLabel: '',
width:100,
iconCls: 'lock',
text: 'Show Password',
toggleHandler: function(btn, st){
if(!st){
 Ext.getCmp('p_acc_pass').setText('Show Password');
 Ext.getCmp('pass_btn').setIconClass('lock');
 Ext.getCmp('acc_pass').getEl().dom.setAttribute('type','password');
 Ext.getCmp('acc_pass').getEl().addClass('x-form-password');
}else{
 Ext.getCmp('pass_btn').setText('Hide Password');
 Ext.getCmp('pass_btn').setIconClass('unlock');
 Ext.getCmp('acc_pass').getEl().dom.setAttribute('type','text');
 Ext.getCmp('acc_pass').getEl().addClass('x-form-text');
}
}
}
Advertisements

Comments are closed.

%d bloggers like this: