如何更改 WebKit 所需 HTML 表单字段的错误消息
Gecko 允许您为 required
HTML 表单字段设置错误消息x-moz-errormessage
< /a>.
WebKit 的等价物是什么?
Gecko allows you to set the error message for required
HTML form fields with x-moz-errormessage
.
What's the equivalent for WebKit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然上面链接的 setCustomValidity() 示例有效,但它没有考虑本机 HTML5 验证测试,而是提供自己的自定义测试。如果您想使用 HTML5 中的类型匹配/模式匹配,请使用
setCustomValidity()
和oninvalid
事件:但是请记住,这不会本地化为用户的浏览器语言,并且无论什么内容无效都会显示(例如,如果未通过
required
检查,它也会显示)While the setCustomValidity() example linked above works, it doesn't take into account the native HTML5 validation test, and instead supplies its own custom test. If you'd instead like to use the type match / pattern match from HTML5, then use
setCustomValidity()
with anoninvalid
event:However bear in mind that this will not be localized to the user's browser language, and will also display regardless of what is invalid (e.g. it will also display if it fails the
required
check)我几乎可以肯定没有,而且看起来不会发生:http://www.w3.org/Bugs/Public/show_bug.cgi?id=10923。
您可能想查看
setCustomValidity()
。对我来说,它在 Chrome 中似乎工作得很好: http://olav.dk/wf2/demo/validation .asp。来源:http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#dom-cva-setcustomvalidity< /a>
I'm almost certain there isn't, and it doesn't look like it's going to happen: http://www.w3.org/Bugs/Public/show_bug.cgi?id=10923.
You might want to check out
setCustomValidity()
. It seems to work fine in Chrome for me: http://olav.dk/wf2/demo/validation.asp.Source: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#dom-cva-setcustomvalidity