Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda