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

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

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