Question

i'm trying to validate input form html5, it works in my local web server, but when upload to hosting doesnt work in this characters: accented characters (vocals) like áéíóú.

so i have tried changing the encoding, is this the best practice?

<META HTTP-EQUIV="Content-Type" CONTENT="text/html;" charset="ISO-8859-1">
<html>
<head></head>
    <body>
        <form>
        Input:<input type="text" pattern="[a-zA-Z0-9ñÑáéíóúü\-_çÇ& ]+"  required />
        <input type="submit" />
        </form>
    </body>
</html> 
Was it helpful?

Solution

The charset described by the meta tag is not the page's encoding, it's just your claim of what the encoding is.

The actual encoding of the page is whatever encoding you used in your text editor to save the file. It is also possible that the hosting changes the encoding of the file but probably unlikely.

You probably want your tag just to be:

<meta charset="UTF-8">

Remember to ensure that you save the file in UTF-8 encoding. (Usually "Encoding" in Save As-dialog)


It is also possible that the hosting is sending an actual HTTP header with charset - this will override any meta tag you have. You can see if this is the case by using Google Chrome Developer Tools Network tab for example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top