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

140
Visualizações
Two Forms in jquery onclick of submit Loading symbol has to change

I am working jquery form. Where I have two forms in a page and when I submit the form one form should say please wait for the button clicked.

And other form display loading symbol instead of please wait. Please find my code in jsfiddle

Here is my reference code

$("form").submit(function() {
  if ($("email").validate().checkForm()) {
   $(this).find('input[type=submit]').prop('disabled', true);
   $(this).find('input[type=submit]').prop('value', 'Please wait...');
 } else if ($("sample_data").validate().checkForm()) {
   $(this).find('input[type=submit]').prop('disabled', true);
   $(this).find('input[type=submit]').prop();
   //How to add gif image here
 }
 });

Here is the HTML code

    <form name="email" action="#" method="post">
  <label for="email">Your Email</label>
  <input name="Email" id="email" type="email">
  <input type="button" value="submit">
</form><br /><br />
<h2>
  Testing Form
</h2>
<form name="sample_data">
  <label for="fname">First Name</label>
  <input name="fname" id="fname_id" type="text"><br />
  <label for="lname">Last Name</label>
  <input name="lname" id="lname_id" type="text">
    <input type="button" value="submit">
</form>
<div class="loadingio-spinner-spinner-cm0pdtzvpde">
  <div class="ldio-rfcqdr7w4x">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
  </div>
</div>

Please let me know What I am doing wrong here.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

  • To call $("form").submit(), you will need to change your input button to submit. That is <input type="submit" value="submit">
  • To prevent the form from being submitted to the server you will need to pass in e, which is the event and call e.preventDefault();. This will allow the JQuery code to continue to run.
  • ("email").validate().checkForm() - I wasn't too sure what you intentions were. If you want to call the checkForm method on the email form then try $("form[name='email'").validate().checkForm(). Alternatively you could add an ID or Class to the form.

Here is a demo https://jsfiddle.net/xptycbu7/

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