title: how to generate error message in form if any of the fields left blank
body: <pre><code>     &lt;form onsubmit="chkform()"&gt;
          &lt;table&gt;
          &lt;tr&gt;&lt;td&gt;name&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="uname"/&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;div id="er1"&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;address&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="add"/&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;div id="er2"&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;/table&gt;
          &lt;/form&gt;
       &lt;script&gt;   
              function chkform()
              {
  
  
                if (document.getElementById("uname").value === "" ) 
                {
  
                 document.getElementById("er1").innerHTML = "name cant be left blank"; 
                 document.getElementById("er1").style.color = "red"; 
                 document.getElementById("er1").style.display = "block"; 
                }
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>i want to show  error message in div, if any of the fields are left blank and this message should disappear when text box is clicked.</p>