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

112
Views
Display error message conditionally in ejs

So, I'm building a login form with express and ejs. When the password Is wrong, my goal is to display a message in the page where the form is. I'm trying to do this:

    if(matchUser.password !== password){
    res.render("index", { error: "Wrong password" })
}

But, i know that if i pass the same variable in other renders, for example, when the page loads, it would work. I'm try to validate in the ejs, like this:

<%= error ? error : "" %>

How can i display it conditionality only passing the variable in one place only?

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