Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

403
Views
¿Por qué cuando algo está mal en las entradas, los errores no se muestran?

Hice una página de registro usando el nodo js e hice algunas validaciones como ejemplo, si la contraseña no coincide con la confirmación de las contraseñas, regresa a la página de registro y enumera los errores debajo de la etiqueta (h1) que se registra pero es regresa a la página de inicio de sesión sin ningún error aquí está mi código:

 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 answers
Answer question

0

Cambie la quinta línea desde abajo a:

 res.render("register", { errors: errors });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!