英文:
How to style input validationMessage
问题
input
类型的电子邮件字段具有验证消息:“请在电子邮件地址中包含@
。'John' 缺少@
。”。当我尝试提交表单时,会显示此消息,我如何样式化此消息?
英文:
input
type email has the validationMessage "Please include an @
in the email address. 'John' is missing an @
.". When I attempt to submit the form, this message displays, how can I style this message?
答案1
得分: 0
"实现自定义错误消息
正如你在之前的HTML验证约束示例中看到的,每当用户尝试提交一个无效的表单时,浏览器会显示一个错误消息。这个消息的显示方式取决于浏览器。
这些自动化消息有两个缺点:
没有标准的方法可以通过CSS更改它们的外观和感觉。
它们依赖于浏览器的语言环境,这意味着你可以拥有一个页面的语言为一种语言,但错误消息却显示为另一种语言,就像下面的Firefox截图中所示。"
这是目前还不可行的。
链接:https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation#Customized_error_messages
英文:
"Implementing a customized error message
As you saw in the HTML validation constraint examples earlier, each time a user tries to submit an invalid form, the browser displays an error message. The way this message is displayed depends on the browser.
These automated messages have two drawbacks:
There is no standard way to change their look and feel with CSS.
They depend on the browser locale, which means that you can have a page in one language but an error message displayed in another language, as seen in the following Firefox screenshot."
This is not possible yet.
https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation#Customized_error_messages
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论