title: Validate Form using Jquery with two submit button
body: <p>I have a single form and there are 2 submit buttons on that with 3 text boxes. On button A text box 1 should validate and n submit button B the other 2 should validate. I have used submit handler and submitting the form using ajax.</p>
  
  <p>My problem is if I click on A then it doesnt call submit handler of B if B is clicked. Whatever is clicked first then the other method doesnt work.</p>
  
  <p>Please help !</p>
  
  <p>My code looks like below :</p>
  
  <pre><code>function set_new_rate(oid) {
      alert("set_new_rate");
      $("#TestForm").validate({
          event: "custom",
          rules: {
              client_new_rate: {
                  required: true,
                  number: true
              },
              agent_new_rate: {
                  required: true,
                  number: true
              }
          },
          messages: {
              client_new_rate: {
                  required: "Required",
                  number: "Invalid Rate"
              },
              agent_new_rate: {
                  required: "Required",
                  number: "Invalid Rate"
              }
          },
          submitHandler: function() {
              var client_new_rate = $('#client_new_rate').val();
              var agent_new_rate = $('#agent_new_rate').val();
  
              var answer = confirm("Set New Rate for this Order?")
              if (answer)
              {
                  $.post('http://localhost/fc/index.php/disp/set_new_rate/',{order_id:oid,client_new_rate:client_new_rate,agent_new_rate:agent_new_rate},function(data){
                      if(data==1)
                      {
                          $('#rateupdated').html('&lt;div id="display_message" class="msg msg-ok" style="margin:0 0 5px 0px;width:180px;"&gt;&lt;p&gt;Rate Updated Successfully!&lt;/p&gt;&lt;/div&gt;');
                          $("#rateupdated").fadeIn(0).fadeOut(5000);
                          $('#rec_ord_cnt_prc'+oid).html(client_new_rate);
                          $('#client_old_rate').html(client_new_rate);
                          $('#agent_old_rate').html(agent_new_rate);
                          $('#client_new_rate').val('');
                          $('#agent_new_rate').val('');
                      }
                  });
              }
          }
      });
  }
  
  function add_note(oid) 
  {
      alert("add_note");
  
      $("#TestForm").validate({
          event: "custom",
          rules: {
              note_description: {
                  required: true
              }
          },
          messages: {
              note_description: {
                  required: "Required"
              }
          },
          submitHandler: function() {
              alert("add_note _ sh");
              var note_description = $('#note_description').val();
              var note_type = $('input:radio[name=note_type]:checked').val();
              var answer = confirm("Add this "+note_type+" Note?")
              if (answer)
              {
                  $.post('http://localhost/fc/index.php/disp/add_note/',{order_id:oid,note_description:note_description,note_type:note_type},function(data){
                      if(data==1)
                      {
                          $('#noteadded').html('&lt;div id="display_message" class="msg msg-ok" style="margin:5px 5px 5px 0px;width:282px;"&gt;&lt;p&gt;Note Added Successfully!&lt;/p&gt;&lt;/div&gt;');
                          $('#note_description').val('');
                          $("#noteadded").fadeIn(0).fadeOut(5000);
                      }                            
                  });
              }
          }
      });
  }
  </code></pre>
  
  <p>I am using Jquery Validate Plugin.</p>