title: javascript how to create a validation error message without using alert
body: <p>I am looking to make a simple form validation error message that displays under the username field. </p>
  
  <p>I cannot seem to figure it out.</p>
  
  <pre><code>&lt;form name ="myform" onsubmit="validation()"&gt;
       Username: &lt;input type ="text" name="username" /&gt;&lt;br /&gt;              
       &lt;input type ="submit" value="submit" /&gt;
        &lt;div id ="errors"&gt;
        &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is my validation script:</p>
  
  <pre><code>function validation(){ 
      if(document.myform.username.value == ""){   //checking if the form is empty
           document.getElementById('errors').innerHTML="*Please enter a username*";
                  //displaying a message if the form is empty
      }
  </code></pre>