title: Form validation in jQuery without using plugin
body: <p>I want to perform client-side validation of a simple form using jQuery, but I can't use any plugins for validation.  I want to display any error messages in  a single alert box.</p>
  
  <p>This is my form:</p>
  
  <pre><code>&lt;form action="" method="post" class="a"&gt;
      Name : &lt;input type="text" class="text" name="name" id="name" /&gt; &lt;br/&gt;
      Address : &lt;input type="text" class="text" name="address" id="address" /&gt; &lt;br/&gt;
      Email: &lt;input type="text" class="text" name="email" id="email" /&gt; &lt;br/&gt;
  
      &lt;input type="button" id="submit" value="Submit" name="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>If a user submits the form without filling any inputs then I need to display 3 error messages in single alert box. Like this</p>
  
  <pre><code>Name can not be empty.
  Address can not be empty.
  email can not be empty.  
  </code></pre>
  
  <p>If only one or two fields remain empty, then I need to control error message according the situation. </p>
  
  <p>Here I tried it using jQuery. But the alerts display in separate boxes: </p>
  
  <p>My jQuery:</p>
  
  <pre><code>$('#submit').on('click', function() {
      valid = true;   
      if ($('#name').val() == '') {
          alert ("please enter your name");
          valid = false;
      }
  
      if ($('#address').val() == '') {
          alert ("please enter your address");
           valid = false;
      }    
  });
  </code></pre>
  
  <p>Here is a <a href="http://jsfiddle.net/WF2J9/14/" rel="nofollow noreferrer">fiddle</a>.</p>
  
  <p>Can anybody tell me how can I figure this out?  Thank you. </p>