PDA

View Full Version : How to disable copy paste and right click on certain textfields



alok000707
23 Mar 2011, 9:47 PM
HI,

I want to disable copy paste and right click functionality on certain textfields like password.

PLease suggest.

Thanks in advance.

ALok

benwhite
21 May 2014, 4:45 AM
quick and dirty...



field.on({
paste: function (field, e, eOpts) {
e.preventDefault();
}
});

Manoj Solanki
13 Jan 2015, 10:52 PM
Hi benwhite

I could not able to do that... because paste event is not triggering on pasting from keyboard as well as from mouse on browser.

Are you doing this on phone/tablet.

Manoj Solanki
13 Jan 2015, 11:01 PM
I had problem with paste event of textfield. It was not triggering.

I had fixed it with following code

Ext.define('Override.field.Input', {
override : 'Ext.field.Input',


initElement : function() {
this.callParent();


this.input.dom.addEventListener('paste', Ext.Function.bind(this.onPaste, this));
}
});



Now you code is working fine... thanks for your help benwhite.