View Full Version : help with TextField

6 Mar 2008, 2:57 AM
hi .. i currently need to make a form containing 4 Ext.form.TextField in a layout similar to that of the serial key form in every commercial application(Eg. windows). my question is how can i make the focus move from textfield to textfield as i type and backwards as i delete.. is there an event on witch i can assign a handler or something like on change(i tried with it but the documentation said that the event is fired just before the lost of focus and i need something to fire everytime i enetr a key..if there is nothing else more elegant i will put it on keypressed but i'm not sure everything will work as smooth as a solution from Ext )
thanx a lot

6 Mar 2008, 6:12 AM

One way you could do is create your textfield components similar to that:

var txtField1 = new Ext.form.TextField({
name: 'serial1',
allowBlank: false

var txtField2 = new Ext.form.TextField({
name: 'serial2',
allowBlank: false
and when they are rendered (because the el is not available before render) you can add you event code like that:

txtField1.el.on('keyup', function(event,el){
if (el.value.length == 3) {
}, this);

txtField2.el.on('keyup', function(event,el){
if (el.value.length == 3) {
} else if (el.value.length == 0) {
}, this);

Of course this could be made more generic, but this is to illustrate the concept.

Hope this helps...