views:

998

answers:

4

Hi,

I've created a custom textInput componenet that handles it's own validation using a private validator. The validation is enabled depending on the state of the component i.e. validation is enable when the components state is "edit".

However, when the state changes from edit the internal validator is set to not enabled but the validation errors on the textbox do not clear - the textInput still has the red border and on mouseover the validation errors come up. What I want to happen is that when a validator is disabled the error formatting and error messages clear from the text input control.

Does anyone have any idea how to do this I tried setting the internal validator instance to enabled = false and dispatching a new focusOutEvent as below but the validation error formatting is still applied to the textInput contrl.

        _validatorInstance.enabled = false;
    //clear the validation errors if any
    dispatchEvent(new FocusEvent(FocusEvent.FOCUS_OUT));

Any ideas?

Thanks

Jon

+1  A: 

As far as I know you can clear the errorString from the error field and the error-formatting should be gone:

myField.errorString = "";
Stevens
A: 

Just note that setting the errorString to blank doesn't dispatch valid or invalid events.

Gregir
A: 

Wrong place to post... can't delete

Gaston
A: 

I'm having exactly the same problem. The difference is that I tinkered with the error styling as the red borders are too thin by default. If I don't use the errorString tool-tip everything works fine when I restore the default aspect upon validation. If I only use the errorString without the custom styling, it also works : when I set the errorString to "" the red border disappears.
Trouble begins when I use both : when I reset the default style and remove the errorString, my thicker custom border disappears as expected but the thin red border of the default error styling lingers behind and simply won't budge...

The styling logic is as below :

 if(valid){
            // Default : taken from the default TextInput styles in the livedocs
            control.setStyle("borderSkin",    HaloBorder);
            control.setStyle("borderColor", 0xAAB3B3);
            control.setStyle("borderStyle", "inset");
            control.setStyle("borderThickness", 1);
        }
        else{
            // Custom red border
            control.setStyle("borderColor", 0xDDE31230);
            control.setStyle("borderThickness",    2);
            control.setStyle("borderStyle", "solid");
        }

Whether I define the errorString after or before the block does not change anything. Any ideas would be much appreciated.

Sandy