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

250
Views
jQuery: delay disable button onclick after the form submission?

So right now I have this:

HTML:

<input type="submit" class="usp-submit usp-submit-default"  onclick="return change(this); "  id="btnSubmit" />

jQuery:

function change( el )

{
    if ( el.value === "Send" )
        el.value = "Sending";
    else
        el.value = "Please wait...";

$("#btnSubmit").attr("disabled", true);
    
}

This does disable the input button and change the value to "Please wait", but the form is not submitted.

I assume this disables the button in the first place and doesn't perform the send action.

I have read somewhere that you can add a delay before .attr("disabled", true) for a few milliseconds so that the form would be submitted first.

Any help from jQuery experts would be appreciated.

Thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to delay, you can use the vanilla js way, setTimeout()

function change( el )
{
    if ( el.value === "Send" )
        el.value = "Sending";
    else
        el.value = "Please wait...";

    setTimeout( () => $("#btnSubmit").prop("disabled", true) , 0);
}
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!