title: Displaying error messages without using alert in javascript/html
body: <p>i'm trying to display a validation error message without using an alert box. But its not working. Previously I've used "innerHTML" successfully. But i don't understand why it doesn't work here. This is my code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function validate()
  {
    if(document.regform.fname.value.length=="")
      {
         document.getElementById("error").innerHTML="error";
      }    
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;header&gt;
     &lt;h1&gt;SIGN UP&lt;/h1&gt;
  &lt;/header&gt;
  &lt;div class="div1"&gt;&lt;img src="img.jpg" width="250px"&gt;&lt;/div&gt;
  &lt;div class="div2" id="div2"&gt;
    &lt;form name="regform" onsubmit="return validate()"&gt;
       &lt;label&gt;&lt;input type="text" name="fName" id="fna"&gt;&lt;/label&gt;
       &lt;input type="submit" name="submit" value="Sign Up" &gt;
       &lt;p id="error"&gt;&lt;/p&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;footer&gt;&lt;/footer&gt;</code></pre>
  </div>
  </div>
  </p>