title: Jquery Validate enable popup if form validates
body: <p>I am using jQuery Validation plugin <a href="http://jqueryvalidation.org/" rel="nofollow">http://jqueryvalidation.org/</a> on a form. I am also using a bit of javascript which means that the response of the form is opened in a popup window. The problem that I have is that if the form doesn't validate but the user tries to submit it then a blank popup window appears. I want the popup to appear only if the form validates. Here is my code:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form id="contactform" action="formmail.php" method="post" name="contactform" onsubmit="popupform(this, 'join')"&gt;
      &lt;input name="env_report" type="hidden" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER" /&gt;
      &lt;input name="recipients" type="hidden" value="me@mydomain.co.uk" /&gt;
      &lt;input type="hidden" value="http://www.mydomain.co.uk/thankyou.html" name="good_url" /&gt;
      &lt;input type="hidden" value="http://www.mydomain.co.uk/error.html" name="bad_url" /&gt;
      &lt;input type="text" placeholder="Name..." name="realname" class="input-text required" required /&gt;
      &lt;input type="email" placeholder="Email..." name="email" class="input-text required" required /&gt;
      &lt;input type="text" placeholder="Phone..." name="phone" class="input-text required" required /&gt;
      &lt;input class="submit button" name="Submit" type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Javascript</p>
  
  <pre><code>$(document).ready(function() {
      $("#contactform").validate();
  });
  
  function popupform(contactform, windowname){
      if (! window.focus)return true;
      window.open('', windowname, 'height=250,width=500,scrollbars=no');
      contactform.target=windowname;
      return true;}
  </code></pre>
  
  <p>If you can help in anyway I would appreciate it. Thank you.</p>