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

153
Views
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 answers
Answer question

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 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!