How to change the validation error language in HTML5?

Asked

Viewed 488 times

0

Is there any way to change the language of the validation error of minLength? Obs: when I try to give Ubmit in a field "required" empty, appears the message Preenche este campo! in Portuguese. Somente o erro de validação do minLength is in English.

Erro de validação em inglês

1 answer

1


Very likely this is because your OS or your Browser is in English, test on another machine, which is with local language Pt that should appear in msg in Portuguese.

Other than that you can try to force a language change in the document’s HTTP header, or by declaring lang on the tag html or with the goal http-equiv in the content hers.

<!DOCTYPE html>
<html lang="pt-br"><!-- recomendado pela W3C -->
<head>
    <meta http-equiv="content-language" content="pt-br"><!-- não recomendado pela W3C -->
    <meta charset="utf-8" />
    <title>Page Title</title>
</head>
<body>

</body>
</html>

To Mozilla makes no reservations as to meta http-equiv, already the W3C does not recommend.

W3C recommends that you declare directly in the HTTP header the Content-Language: pt-br or on the tag html

This use of content-language value of a http-equiv attribute is disapproved by the HTML specification and should no longer be used. Instead, you should always use a lang attribute in html tag to declare the default language of the text on the page.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.