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');
}
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: