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

158
Views
¿Cómo detener el formulario 'enviar' cuando no es válido y muestra un mensaje de error?

cuando coloco una identificación y una contraseña no válidas, la página solo muestra el mensaje de error y actualiza la página. Como no quiero que la página se actualice, cómo detener el 'enviar'.

 const accounts = [ ["myaccount", "mypassword1"], ["myaccount2", "mypassword2"], ]; const event = document.getElementById("info"); event.addEventListener("submit", (e) => { accounts.forEach((element) => { if (element[0] === id && element[1] === password) { pass = true; } }); if (pass) { signInForm.action = "builder.html"; } else { e.stopPropagation(); document.getElementById("error").innerText = "error"; } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intente usar el método event.preventDefault().

https://www.w3schools.com/jsref/event_preventdefault.asp

 else { e.preventDefault(); e.stopPropagation(); document.getElementById("error").innerText = "error"; }

Esto también podría ayudar: https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation

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!