未启用验证时清除 textInput 上的验证

发布于 2024-07-26 19:26:41 字数 553 浏览 6 评论 0原文

我创建了一个自定义 textInput 组件,它使用私有验证器处理它自己的验证。 根据组件的状态启用验证,即当组件状态为“编辑”时启用验证。

但是,当状态从编辑更改时,内部验证器设置为未启用,但文本框上的验证错误未清除 - textInput 仍然具有红色边框,并且鼠标悬停时会出现验证错误。 我想要发生的是,当禁用验证器时,错误格式和错误消息会从文本输入控件中清除。

有谁知道如何做到这一点我尝试将内部验证器实例设置为enabled = false并分派一个新的focusOutEvent,如下所示,但验证错误格式仍然应用于textInput控件。

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

有任何想法吗?

谢谢乔恩

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜唯美灬不弃 2024-08-02 19:26:41

据我所知,您可以从错误字段中清除 errorString,并且错误格式应该消失:

myField.errorString = "";

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

myField.errorString = "";
梦亿 2024-08-02 19:26:41

我发现与使用 errorString 相关的问题用于从错误字段中清除 errorString。 一旦错误字符串被清除(以编程方式),绑定到验证器的组件就不会在后续验证中显示错误提示。

请将 errorString 的使用替换为 ValidationResultEvent,以编程方式触发此事件,如下所示:

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

此问题对于使用 4.0 SDK 编译的代码来说很普遍,而从 4.5 SDK 开始,此问题已得到修复。

这是 JIRA 中报告的一个错误:
http://bugs.adobe.com/jira/browse/SDK-29270

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

┈┾☆殇 2024-08-02 19:26:41

请注意,将 errorString 设置为空白不会调度有效或无效事件。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文