title: Submitting a PHP form with onClick
body: <p>So I currently have a download link and an input field for an email address on my website.</p>
  
  <p>In order to download the file you first need to put in your email.</p>
  
  <p>I use a form to do this, with the email field being an input field and the download button being a submit button.</p>
  
  <p>I like HTML5's form validation (the required fields, field types etc, it all looks very nice).</p>
  
  <p>The problem is that if I use onClick in my submit button then none of the nice form validation works.</p>
  
  <pre><code>&lt;form&gt;
       &lt;input type="email" id="email" placeholder="Please enter email" required&gt;
  
       &lt;input type="submit" class="btn" onclick="downloadWin()" value="Windows"&gt;
       &lt;input type="submit" class="btn" onclick="downloadOsx()" value="Osx"&gt;  
  &lt;/form&gt;
  
  
  &lt;script&gt;
      function downloadWin(){
          event.preventDefault();
          var email = $("#email").val();
          if(email != ''){
              if(validateEmail(email)){
                  location.href='http://s/index.php?page=downloadWin&amp;email='+email;
              }
          }
      }
  
      function downloadOsx(){
          event.preventDefault();
          var email = $("#email").val();
          if(email != ''){
              if(validateEmail(email)){
                  location.href='http://s/index.php?page=downloadOsx&amp;email='+email;
              }
          }
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>This might not be the cleanest way to do it, so please if you think you know a better way tell me :)</p>