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

167
Visualizações
Email Validation using setCustomValidity

I got the following code for

// Validating Email

function validateEmail() {
    var mail = document.getElementById("email").value;
    var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{3})+$/;
    var endEmail = "@gmail"
    if(mail.match(mailformat) && (mail.charAt(x.length-1) == endEmail) ) {
mail.value += ".com"
        alert(mail)
        return true;
    
} else if (email.validity.valueMissing) {
        console.log("Email is missing")
        email.setCustomValidity("Please fill in the email.");
    } 
}

I have a problem with checking the email. The logic I am trying to implement is to check whether the email contains “gmail” after “@” and to validate the email ends in “.com” (This check is only mandatory if the email field has “gmail” after “@”.). In the case of gmail being in the email after “@” and the ending being something other than “.com”, I wanna fix this for the user and let the submission go through after the fix.

about 4 years ago · Juan Pablo Isaza
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