title: How to prevent form submission using confirm dialog?
body: <p>I have a form with two submit buttons - Save and Submit. Here is the HTML markup for these buttons:</p>
  
  <pre><code>&lt;form id="formBooking"&gt;
  &lt;input type="submit" name="FormAction" id="Save" value="Save"&gt;
  &lt;input type="submit" name="FormAction" id="Submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I created two functions for showing a confirm dialog depending on which FormAction was chosen:</p>
  
  <pre><code>function confirmSave()
  {
      return confirm('This operation will save your booking.');
      }
  
  function confirmSubmit()
  {
      return confirm('This operation will submit your booking.');
  
  }
  </code></pre>
  
  <p>And here is my JQuery to handle the submit click:</p>
  
  <pre><code>$("#formBooking").on('click', 'input[type="submit"]', function (e) {
      if (!$("#formBooking").valid()) { //uses Jquery validator plug-in to ensure form is ok
          e.preventDefault();
          return;
      } else {
          // HERE I NEED TO FIRE THE CONFIRM DIALOG DEPENDING ON IF ITS A SAVE OR SUBMIT
          var options = {
              data: {
                  FormAction: $(this).attr("value") // is it a save or submit?
              },
              forceSync: true,
              uploadProgress: function (percentComplete) {},
              beforeSend: function () {
  
              },
              success: function () {
  
              },
              complete: function () {
  
              }
          }
          $("#formBooking").ajaxSubmit(options);
          // return false to prevent normal browser submit and page navigation 
          return false;
      }
  });
  </code></pre>
  
  <p>So when a users clicks on either of the submit buttons, JQuery should fire a <code>confirmSave()</code> or <code>confirmSubmit()</code> function. If the users clicks "cancel" in the confirm dialog then I don't want the form to submit at all. </p>
  
  <p>I tried adding <code>"onClick: confirmSave()"</code> to the button itself which works, but when the user clicks cancel it still submitted the form!</p>
  
  <p>Any suggestions please?</p>