extjs - Change color of the field when condition is satisfied -
for example, have textfield input type 'email'. have set default color of field pink. if input in proper email format, want textfield's color changed white. how do that?
the eg code:
xtype: 'textfield', labelwidth : 250, fieldstyle: 'background-color : #f5a9a9', vtype : 'email', fieldlabel: 'email address'
in case first need check weather input value email or not. using var fieldvalidation = ext.form.field.vtypes.email(val);
if fieldvalidation true input value email. once verified input value change our background color. this.setfieldstyle("background-color : #ffffff")
your code :
{ xtype: 'textfield', fieldstyle: 'background-color : #f5a9a9', vtype : 'email', fieldlabel: 'email address', validator : function(val){ var fieldvalidation = ext.form.field.vtypes.email(val); if(fieldvalidation == true){ this.setfieldstyle("background-color : #ffffff"); } } }
i created fiddle you. please have look. working fiddle.
also attaching doc of vtype understand properly. doc
Comments
Post a Comment