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

404
Vistas
Why when something is wrong in inputs the errors doesn't display

I made a register page using node js and I made some validations as an example if password doesn't match with confirm the passwords it returns back to the signup page and listing the errors beneath the the (h1) tag which is sign up but it's returns back to the sign page without any errors here's my code:

module.exports.signup_post = (req,res)=>{
let {firstName,lastName,username,email,password,password2} = req.body;
console.log(
    firstName,
    lastName ,
    username,
    email,
    password,
    password2
    );

let errors =[];

if (!firstName || !lastName || !username || !email || !password || !password2){
    errors.push({message:'please enter the all fields'});

}
if (password.length<6){
    errors.push({message:'password should be at least 6 characters'})
}
if (password!= password2){
    errors.push({message:'passwords do not match'})
}
if (errors.length > 0){
    res.render('register');
    
}else{
    res.render('login')
  }

}


<ul>
        <% if (typeof errors != 'undefined'){ %>
            <% errors.forEach(error =>{ %>
                <li><% error.message %></li>
                <% }) %>
            <% } %>
    </ul>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Change the fifth line from the bottom to:

res.render("register", { errors: errors });
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