Learn More... SQLsnap Logo. SQLsnap Screenshot. Buy Now or Learn More!

Force an ExtJS textfield to uppercase

May 11th, 2011

To style a textfield to uppercase you only need to add a style to the textfield’s config option.
For example;

                   {
                        xtype:'textfield',
                        fieldLabel:'User ID',
                        itemId:'userid',
                        style:'text-transform: uppercase',
                        listeners:{
                            scope:this,
                            specialkey: function(f,e){
                                if(e.getKey()==e.ENTER){
                                    Ext.Msg.alert('','You typed '+
                                        loginForm.getComponent('userid').getValue().toUpperCase());
                                }
                            }
                        }

                    }

In the example above we used ‘text-transform: uppercase’ in the style config to force uppercase. (as shown on line 5)
This takes care of the visual aspect.
When you access the field in your js you still need to use myField.toUpperCase(); (as shown on line 11)

Jr


Posted in: Extjs 3.
Subscribe: RSS 2.0 feed.

blog comments powered by Disqus
  • « Older Entries
  • Newer Entries »