title: how to not submit a form in js
body: <p>I want to not submit the form if the inputs are empty, here is my code:</p>
  
  <pre><code> &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;
  The X/O Game
  &lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  var check = function () {
      var x = document.getElementById("x").value;
      var o = document.getElementById("o").value;
      var p = document.getElementById("p").value;
  
      if(p==""||(x==""&amp;&amp;o=="")){
          alert("fill the form!");
          return false;
      }
  
      return true;
  };
  
  $('#formm').submit(function(e){
      var shouldSubmit = check();
  
      if (!shouldSubmit) {
          e.preventDefault();
      }                                    
  });
  
  $('#emotion input:radio').addClass('input_hidden');
  $('#emotion label').click(function(){
      $(this).addClass('selected').siblings().removeClass('selected');
  });
  &lt;/script&gt;
  &lt;link rel="stylesheet" type="text/css" href="style/style.css" /&gt;
  &lt;body&gt;
  &lt;div&gt;
  Please enter your name &amp; choose your character before start playing:
  &lt;/div&gt;
  &lt;div&gt;
  &lt;form method=post action=game.php name="formm"&gt;
  Name:&lt;br&gt;
  &lt;input type=text name=player id=p&gt;
  &lt;/div&gt;
  &lt;div&gt;
  Character:&lt;br&gt;
  &lt;input 
    type="radio" name="emotion" value="xChar"
    id="x" class="input-hidden" /&gt;
  &lt;label for="x"&gt;
    &lt;img src="images/x.png " /&gt;
  &lt;/label&gt;
  &lt;input 
    type="radio" name="emotion" value="oChar"
    id="o" class="input-hidden" /&gt;
  &lt;label for="o"&gt;
    &lt;img src="images/o.png" /&gt;
  &lt;/label&gt;
  &lt;/div&gt;
  &lt;div&gt;
  &lt;input type=submit value=Play&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
      $('#formm').submit(function(){
          return  f;                                       
      });
  </code></pre>
  
  <p>this function is called when the user clicks on the submit button.
  the form is subbmited even though the inputs are empty, where is the wrong?</p>