Search code examples
extjsextjs3

How to use the onkeyup event to a TextField?


I want to use onkeyup event of text field, so we can count that character when enter the text.


Solution

  • You are almost there. In the doc field key events, it is written that key events get fired only if enableKeyEvents is set to true.

               {
                    xtype: 'textfield',
                    fieldLabel: 'Address',
                    width: '100%',                    
                    enableKeyEvents : true,
                    listeners: { 
                        keyup : function(obj) { 
                         alert('test fire ' + obj.getValue()); 
                         } 
                       }
                },