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

155
Vistas
Is there an option for 2 seconds after hitting the submit button display an alert and then complete the form request?

I have the code

<form id="myForm" method="POST" novalidate="">
<input type="text" id="NameInput" name="NameInput">
<button type="submit">Complete</button>
</form>

I want to show an alert like "The form has been submited!" and after clicking submit the form and complete the request

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

0

Add an event listener for the submit event that prevents the form from submitting by calling Event.preventDefault(), then use setTimeout to execute a function which alerts and submits the form programmatically after 2000 milliseconds:

myForm.addEventListener('submit', function(e) {
  setTimeout(function() {
    alert("The form has been submited!")
    myForm.submit();
  }, 2000)
  e.preventDefault()
})
<form id="myForm" method="POST" novalidate="">
  <input type="text" id="NameInput" name="NameInput">
  <button type="submit">Complete</button>
</form>

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