title: how to disable the action of the form via jquery?
body: <p>is it possible to disable the submission of the form given a certain condition?
  here's my sample code</p>
  
  <pre><code>        &lt;form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"&gt;
          &lt;input type="hidden" name="cmd" value="_cart" /&gt;
          &lt;input type="hidden" name="upload" value="1" /&gt;
          &lt;input type="hidden" name="business" value="test@gmail.com" /&gt;
          &lt;?php
            $i = 1;
            foreach($_SESSION['cart'] as $id =&gt; $qty):
            $product = $myCart-&gt;getProduct($id);
  
          ?&gt;
          &lt;input type="hidden" name="item_name_&lt;?php echo $i; ?&gt;" value="&lt;?php echo $product['ProductName']; ?&gt;"&gt;
          &lt;input type="hidden" name="item_number_&lt;?php echo $i; ?&gt;" value="&lt;?php echo $product['ProductID']; ?&gt;"&gt;
          &lt;input type="hidden" name="amount_&lt;?php echo $i; ?&gt;" value="&lt;?php echo $product['ProductOverridePrice']; ?&gt;"&gt;
          &lt;input type="hidden" name="quantity_&lt;?php echo $i; ?&gt;" value="&lt;?php echo $qty; ?&gt;"&gt;
        &lt;?php
          $i++;
          endforeach;
        ?&gt;
          &lt;input type="hidden" name="currency_code" value="USD"&gt;
          &lt;input type="hidden" name="lc" value="US"&gt;
          &lt;input type="hidden" name="rm" value="2"&gt;
          &lt;input type="hidden" name="shipping_1" value="&lt;?php echo $shipping; ?&gt;"&gt;
          &lt;input type="hidden" name="return" value="http://testsite/thankyou.php"&gt;
          &lt;input type="hidden" name="cancel_return" value="http://testsite/"&gt;
          &lt;input type="hidden" name="notify_url" value="http://testsite/paypal.php"&gt;
          &lt;input type="image" src="images/shopping-cart/check-out-btn.png" name="pay now" value="pay" /&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>let's say I have a condition where the form should "not" be submitted if
  $_SESSION['cart'] is empty , how to do that ?</p>
  
  <p>I tried one of the answers at the bottom..I placed the code at the bottom of the file like this</p>
  
  <pre><code>&lt;?php
  if(!is_array($_SESSION['cart']) &amp;&amp; empty($_SESSION['cart'])):
  ?&gt;
  &lt;script&gt;
  $('form').on('submit', function(e){
     e.preventDefault();
  });
  &lt;/script&gt;
  &lt;?php
  endif;
  ?&gt;
  </code></pre>
  
  <p>didn't work..when i push the checkout button it still goes to the paypal sandbox page</p>