title: Form Validation without Alerts
body: <p>I was wondering if there's a way to validate the form without using alerts. Like usually you would see red text beside the input box if you typed in the wrong information or something. And I don't want to use Jquery. I've included a div for the red text messages in the html - namemsg, commentmsg, emailmsg.</p>
  
  <p>So far I've only got the code with alerts. 
  JavaScript: </p>
  
  <pre><code>function validateUser()
  {
      var x=document.forms["myForm"]["email"].value;
      var atpos=x.indexOf("@");
      var dotpos=x.lastIndexOf(".");
      if (atpos&lt;2 || dotpos&lt;atpos+2 || dotpos+2&gt;=x.length)
      {
          alert("Not a valid e-mail address");
          return false;
      }
  
      {
          alert("Valid Input");
      }
  
      return true;
  }
  </code></pre>
  
  <p>Html </p>
  
  <pre><code> &lt;form name="myForm" method="post"&gt;
      &lt;label&gt;*Name:&lt;/label&gt;
      &lt;input type="text" name="name" title="Enter a your name" placeholder="Your Name" onclick="select()" required/&gt;
      &lt;div id="namemsg"&gt;&lt;/div&gt;&lt;br/&gt;
  
      &lt;label&gt;*E-mail:&lt;/label&gt;
      &lt;input type="text" name="email" title="Enter a valid email address" placeholder="me@example.com" onclick="select()" required/&gt;
      &lt;div id="emailmsg"&gt;  &lt;/div&gt;&lt;br/&gt;
  
      &lt;label&gt;*Comment:&lt;/label&gt;
      &lt;textarea name="comment" title="Enter your comments" placeholder="Enter your comments." onclick="select()" required/&gt;&lt;/textarea&gt;
      &lt;div id="commentmsg"&gt;  &lt;/div&gt;
      &lt;label id="error"&gt; &lt;/label&gt; &lt;br/&gt;
      &lt;input type="submit" value="Submit" onclick="return validateUser()"&gt; 
  &lt;/form&gt;
  </code></pre>