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

163
Visualizações
trying to fix form validation

i'll try to make form validation by giving the background colour and focus to each input when input is empty but, it turns out even though i fill the input, it still focus on the first input. It is not continue to check on the next input

I have tried with this code

    var fName=document.getElementById("in_fName");
    var lName=document.getElementById("in_lName");

//first name validation
        if (fName.innerHTML===""){
            alert("he");
            fName.style.background="#DE8971";
            fName.style.color="#FFE9D6";
            fName.focus();
        } else {
            alert("here");            
            fName.style.background="white";
            fName.style.color="black";
            return false;
        }

       //last name validation
       if (lName.innerHTML===""){
             lName.style.background="#DE8971";
             lName.style.color="#FFE9D6";
            lName.focus();
        }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Why not use require fields in the html section. By doing that you will not have to check for validation in JavaScript.

It would be better if you could also share your html code.

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