Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
is there any way to remove the default error from input type email when user enter the incorrect email address?

is there any way to remove the default error from input type email when the user enters the incorrect email address? as I'm working on form validation with an email address. i can see default error from on input email but not on my console.

<div class="registration-box">
        <form id="form-data">
          <input
            type="email"
            placeholder="Email Address"
            class="email-id"
            id="email-data"
          />

          <span class="btn-box"
            ><input type="submit" class="submit" value="submit" /></span>
        </form>
      </div>
      <div class="error-msg">Please provide a valid email</div>
const formData = document.getElementById("form-data");
const emailAdd = document.querySelector("input[type='email']");
const emailReg = /^[(\w\d\W)+]+@[\w+]+\.[\w+]+$/i;

formData.addEventListener("submit", (e) => {
  e.preventDefault();

  if (emailReg.test(emailAdd.value)) {
    console.log("correct");
  } else {
    console.log("error");
  }
});
almost 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can accomplish this by disabling the form authentication, when you do this tho you need to make sure that your authentication is water proof.

We all know how ugly the stock validation is by default, and you can disable this by adding novalidate to your <form>

Here is a example of the validation that shows the user a custom error message if email.checkValidity() returns false

let email = document.getElementsByClassName("email-field")[0];

function validate_email() {
  if (!email.checkValidity()) {
    document.getElementById("error").innerHTML = "E-mail is not correct";
    return false;
  } else {
    document.getElementById("error").innerHTML = "";
    return true;
  }
}
console.log("email " + email.value + "  " + email.checkValidity());
<form onsubmit="return validate_email(this)" novalidate>
  <input type="email" placeholder="Email Address" class="email-field" required>
  <p id="error" style="color: red;"></p>
  <input type="submit" onsubmit="return validate_email(this)">
</form>

Hope this helped, if it didn't please let me know, and I will see what I can do to further help you.

almost 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda