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

223
Vistas
How to avoid the user from repeating to fill in the form if there is an error?

Problem: I'm doing a form to be filled by the user. Once the user clicks submit, if there is an error in the form, it will show an alert. However, when the user clicks "ok" the form will reset all the fields that have been filled so the user needs to repeat in fill in the form all over again.

Question: How to fix this so that when the user clicks "ok" the data is still there?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

To stop the page from re-loading add return false; after alert statement, it stops the default action from taking place from the form submit.

alert("Please fill in all mandatory fields");
return false;
about 4 years ago · Juan Pablo Isaza Denunciar

0

You should reset form:

document.getElementById("formId").reset();
about 4 years ago · Juan Pablo Isaza Denunciar

0

The <button> element, when placed in a form, will submit the form automatically unless otherwise specified. You can use the following 2 strategies:

  • Use <button type="button"> to override default submission behavior.
  • Use event.preventDefault() in the onSubmit event to prevent form submission.
var form = document.getElementById("myForm");
function handleForm(event) { event.preventDefault(); } 
form.addEventListener('onSubmit', handleForm);
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