title: Using jQuery to prevent form submission when input fields are empty
body: <p>The solution should be pretty straightforward. I'm trying to prevent the form from submitting properly when no value is found within the input boxes. Here's my JSFiddle: <a href="http://jsfiddle.net/nArYa/7/">http://jsfiddle.net/nArYa/7/</a></p>
  
  <p>//Markup</p>
  
  <pre><code>&lt;form action="" method="post" name="form" id="form"&gt;
  &lt;input type="text" placeholder="Your email*" name="email" id="email"&gt;
  &lt;input type="text" placeholder="Your name*" autocomplete=off name="name" id="user_name"
  &lt;button type="submit" id="signup" value="Sign me up!"&gt;Sign Up&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>//jQuery</p>
  
  <pre><code>if ($.trim($("#email, #user_name").val()) === "") {
      $('#form').submit(function(e) {
          e.preventDefault();
          alert('you did not fill out one of the fields');
      })
  } 
  </code></pre>
  
  <p>As you can see in the JSFiddle, the problem is that when I type something into both fields, the alert box STILL pops up. I'm having a hard time figuring out why. Is there something wrong within my
      <strong>if($.trim($"#email, #user_name").val()) === "")</strong> ?</p>