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

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

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