PDA

View Full Version : Update Ext.form.Text inputCls



sissonb
19 Aug 2011, 1:30 PM
I have a text form and want to update the inputCls property on keyup. This is how I am currently trying, but it's wrong.


new Ext.form.Text({
name : 'referredFrom',
id : 'referredFrom',
inputCls:"invalid",
label: 'Account Number',
listeners:{
keyup:function(){

var isValid = true;
if(isValid){
Ext.getCmp("referredFrom").inputCls = "valid";
}
else{
Ext.getCmp("referredFrom").inputCls = "invalid";
}
}
}
});

Any Ideas?
Thanks

sissonb
19 Aug 2011, 2:58 PM
Currently I am doing it this way, but really don't like the solution.


new Ext.form.Text({
name : 'referredFrom',
id : 'referredFrom',
label: 'Account Number',
listeners:{
keyup:function() {


if (this.getValue() === "") {
var defaultClass = "x-input-text";
Ext.getCmp("referredFrom").el.dom.children[1].children[0].setAttribute("class", defaultClass);
}
else {
var unknownClass = "x-input-text unknown";
Ext.getCmp("referredFrom").el.dom.children[1].children[0].setAttribute("class", unknownClass);
}
}
}
});

If there is a better way please let me know.
Thanks