title: Stay in same page when form is not submitted
body: <p>I have the following form</p>
  
  <pre><code> &lt;form id="postForm" action="post.php" method="post"&gt;
  </code></pre>
  
  <p>and a post.php file. Both of them are working properly. I just need to make sure that when I check the checkbox the form is submitted and when I don't, it should stay on the same page.I found a few tutorials using jquery and ajax, but I was required to use Javascript. Can anyone help, thank you in advanced</p>
  
  <pre><code>function validate() {       
      if(document.getElementById('postTW').checked){
          document.getElementById("postForm").submit();
      }
      else{   
      }    
  }
  </code></pre>