Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda