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