2

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

4

3 回答 3

8

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

myField.errorString = "";
于 2009-07-13T18:04:33.207 回答
3

I found issues relating to use of errorString being used to clear the errorString from the error field. Once the errorString is Cleared(programmatically) the Component bound to the validator doesn't show up the errortip on subsequent validation.

Please replace the use of errorString with ValidationResultEvent, fire this programmatically like this:

var evt:ValidationResultEvent = new ValidationResultEvent(ValidationResultEvent.VALID);
validatorInstance.dispatchEvent(evt); 

This issue is prevalent for the code compiled using 4.0 SDK, where as 4.5 SDK onward this has been fixed.

It's a bug reported in JIRA: http://bugs.adobe.com/jira/browse/SDK-29270

于 2012-05-02T12:52:38.227 回答
0

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

于 2010-06-11T00:20:47.273 回答