Detect which submit button was clicked
<p>I know this question sounds a lot like a bunch of others that are out there, but I swear I can't find the right solution anywhere. I have a legacy form that has multiple submit buttons. If one is clicked, I need to do a bit of client-side validation and potentially stop the submit. If the other is clicked, I don't need to do this validation.</p>

<p>What I'm finding is that if I create a <code>.submit()</code> handler, I can't seem to access which button was actually clicked. On the other hand, if I capture the <code>.click()</code> event of the button I need to worry about, then I can't prevent the form from submitting via <code>.preventDefault()</code> (or <code>.stopImmediatePropagation()</code>).</p>

<p>Here's the most recent iteration of the code that attempts to use the buttons <code>.click()</code> handler:</p>

<pre><code>$('#nextButton').click( function( e ) {
  e.preventDefault(); // The form submits anyway (which kind of makes sense)
  // return false also doesn't prevent the submission

  // If any session question is unanswered, abort
  /* $('#registrants input:text[id$="Answer"]').each( function( i, input ) {
    if( $.trim( $(input).val() ) == '' ) {
      submit = false;
    }
  });*/
});
</code></pre>

<p>What am I missing here? There <em>has</em> to be a way to do this and it seems like it should be fairly simple, but I'll be damned if I've had any luck at all.</p>

<p>Thanks.</p>
