HTML5的国际化 [英] Internationalization at HTML5
问题描述
如何更改HTML5的消息(或根据浏览器的语言自动更改剂量?)
How can I change the messages of HTML5 (or doses it change according to browser's language automatically?)
例如:
<!DOCTYPE HTML>
<html>
<body>
<form action="demo_form.asp" method="get">
E-mail: <input type="email" name="user_email" /><br />
<input type="submit" />
</form>
</body>
</html>
当我运行此代码时(来自 W3schools )在Opera上写一个无效的电子邮件地址,它说
When I run this code (from W3schools) at Opera and write a non valid e-mail address it says
Please enter a valid email address
如何更改用另一种语言代替英语或将警告更改为我想要的内容?
How can I change it to another language instead of English or change the warning to what I want?
推荐答案
嗯有不同的选择。
-
您可以使用formnovalidate禁用表单(或字段)的表单验证,并使用javascript(和serverside ofcourse)提供自定义错误消息。
You can disable the form validation of the form (or the field) with formnovalidate and provide a custom error message with javascript (and serverside ofcourse).
您可以使用javascript并使用 .setCustomValidity()
方法提供(自定义)错误消息,但它旨在向该字段添加额外的规则。
You can use javascript and use the .setCustomValidity()
method to provide a (custom) error message but it is intended to add extra rules to the field.
您可以使用 x-moz-errormessage
设置自定义错误消息。但是使用它你需要知道这不是标准。
You can use x-moz-errormessage
to set a custom errormessage. But using this you need to know that this is not a standard.
这篇关于HTML5的国际化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!