title: Submit form using a href a long with validation
body: <p>I'm having trouble with this small script.
  I have a list with products. Each product can be added to cart from this list.</p>
  
  <p>But I need to validate that variants is choosen. 
  The validation is working okay, but the submit do not.</p>
  
  <p><strong>JS</strong>:</p>
  
  <pre><code>function submitForm() {
      if ($('#variants').val() !== '') {
          $(this).closest('form').submit();
      } else {
          alert("You need to pick variant");
      }
  }
  </code></pre>
  
  <p><strong>HTML</strong>:</p>
  
  <pre><code>&lt;form id="form" action="FormPost.aspx"&gt;
      &lt;select name="variants" id="variants" class="variants"&gt;
          &lt;option value=""&gt;Select variant&lt;/option&gt;   
          &lt;option value="Black"&gt;Black&lt;/option&gt;
          &lt;option value="White"&gt;White&lt;/option&gt;
          &lt;option value="Red"&gt;Red&lt;/option&gt;
      &lt;/select&gt;
      &lt;a href="javascript:submitForm();" class="addToCart buybtn_small text-left pull-right"&gt;Buy&lt;/a&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><a href="http://jsfiddle.net/pthv/k3zmon2d/" rel="nofollow"><strong>JSFiddle</strong></a></p>