Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't make allowBlank true visually in ExtJS

I have textfield:

{
                xtype : 'textfield',
                id: 'specialCode',
                allowBlank: true,
                fieldLabel : 'Special Code',
                name : 'specialCode'
            }

I do make it required when a checkbox is checked with

Ext.getCmp('specialCode').allowBlank = false;
Ext.getCmp('specialCode').validateValue(Ext.getCmp('specialCode').getValue());

I becomes red and it becomes required.

Then when another checkbox is cheked I use this code

Ext.getCmp('specialCode').allowBlank = true;

It becomes not required but the red border does not go away. I need to click the field and some other place in order to remove the red border.

like image 509
ilhan Avatar asked Feb 23 '23 00:02

ilhan


1 Answers

use clearInvalid on the field too to reset it's invalidation style.

Ext.getCmp('specialCode').allowBlank = true;
Ext.getCmp('specialCode').clearInvalid();
like image 53
ChrisR Avatar answered Feb 25 '23 16:02

ChrisR