3

I developed a simple form, and when I click on the button it checks that all fields are entered correctly. If not, a message appears below the field, very standard

The problem lies in two words, "minimum" and "maximum". Location is correct, words are being displayed, but online on hosting is not.

On the pages is the <meta charset="UTF-8"> and I tried too <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>. And also inserted in the script tag <script src="js/contatPage.js" charset="UTF-8" type="module"></script> and <script src="js/contatPage.js" charset="iso-8859-1" type="module"></script>. None of these worked

Function that receives the input, checks and calls the function to create the message

...
function check(e)
   ...
   {else if(e.value.length < e.minLength){
      createMessage(e, `Quantidade mínima de caracteres ${e.minLength}`) 
   }
   ...
...

Error example image enter image description here

Bjorn Ruiz
  • 546
  • 2
  • 4
  • 15
  • 3
    You will need to use HTML characters instead. For example, `mínima` should use `í`, so HTML will apply the right character. Check this: [About Unicode](https://www.w3schools.com/charsets/ref_utf_latin1_supplement.asp). Keep in mind you will need to use the innerHTML property if you're using innerText to set the message. – astroxii Nov 29 '21 at 14:27
  • Can you show the code that adds it to the DOM? – skara9 Nov 29 '21 at 14:27
  • what charset did you specify in html? try `` in `head` tag. – Greg-- Nov 29 '21 at 14:41

1 Answers1

1

Some special letters can't be typed directly to HTML, and must be inserted using the HTML special characters, the main are all at W3Schools, and most were added in VS Code, so when you type '&' inside a HTML File, it suggests some for you. Check more about here, navigate in the left side.

In your script:

function check(e) // e is probably a text element, right?
{
   // Your conditions for message...
   createMessage(e, `Quantidade m&iacute;nima de caracteres ${e.minLength}`)
   // In this "createMessage" function, you will need to use the element's
   // innerHTML property, so the HTML character (&iacute = í) will be parsed
}

// For example...
function createMessage(e)
{
   e.target.innerHTML = "Sua mensagem &eacute; digitada aqui, meu jovem!";
}

Good luck, hope this helps!

astroxii
  • 146
  • 2
  • 8