title: How to check multiple conditions in an IF statement with dialog confirms
body: <p>I am trying to work out if a user has clicked <code>OK</code> or <code>Cancel</code> in a Javascript alert box, depending on which button was clicked on the page. I previously had two submit buttons on a page which were <code>Save</code> and <code>Send</code>. But since then I've added a <code>Create</code> submit button and can't seem to fit it into my code.</p>
  
  <p>Here is my code which works when there is only a <code>Save</code> and <code>Send</code> submit button on the page:</p>
  
  <pre><code>$("#form").on('click', 'input[type="submit"]', function(e) {
      if (!$("#form").valid() 
  || !($(this).is('#Save') ? confirmAction('SaveRecord') : confirmAction('SendRecord'))) {
          e.preventDefault();
          return;
      } 
      else { 
        //continue to process the form 
      }
  });
  </code></pre>
  
  <p>What's happening is that when the user clicks on a submit button, its checking that the form is valid and that if the user clicked <code>Save</code> then to show and check they clicked OK on the <code>SaveRecord</code> confirmAction() alert box. Or if they didn't click on <code>Save</code> then it assumes they clicked on <code>Send</code> and shows and checks that the user confirmed the <code>SendRecord</code> confirmAction() alert box.</p>
  
  <p>I now want to add a <code>Create</code> button to the page. When this button is clicked it should show and check that the user clicked OK on the <code>CreateRecord</code> confirmAction() alert box. </p>
  
  <p>I tried this but it doesn't work:</p>
  
  <pre><code>$("#form").on('click', 'input[type="submit"]', function(e) {
      if (!$("#form").valid() 
  || !($(this).is('#Create') confirmAction('CreateRecord')) //this doesn't work!! 
  || !($(this).is('#Save') ? confirmAction('SaveRecord') : confirmAction('SendRecord'))) {
          e.preventDefault();
          return;
      } 
      else { 
        //continue to process the form 
      }
  });
  </code></pre>
  
  <p>How can I ensure that when <code>Create</code> is clicked it will only continue if the user confirmed that action? I would prefer not to use the <code>?</code> operator for OR and have each button on its own line. Something like this:</p>
  
  <pre><code>if (!$("#form").valid() 
      || !($(this).is('#Create') confirmAction('CreateRecord'))
      || !($(this).is('#Save') confirmAction('SaveRecord')) 
      || !($(this).is('#Send') confirmAction('SendRecord'))) {
              e.preventDefault();
              return;
          } 
  </code></pre>
  
  <p>How could I do it?</p>