Search code examples
apache-flexactionscript-3validationflex3uicomponents

Clear validation on textInput when validation is not enabled


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


Solution

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

    myField.errorString = "";