title: .innerHTML in Javascript
body: <p>I'm trying to validate a login page with a div to display the errors in , I'm using innerHTML to change the empty text in the div with the error occured , the problem is that the error msg is written and disappears just in a second</p>
  
  <p>here is the code</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;
      Sign up for a membership @ Ay 7aga.com
  &lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  function check(){
  var x = "";
  if(document.getElementById('user').value =="")
      x+="Enter user name -";
  if(document.getElementById('password').value =="")
      x+="Enter password";
  document.getElementById('error1').innerHTML = x;
  
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div name="error" id="error" style="width:1200px;background-color:red"&gt; 
  &lt;p name="error1" id="error1"&gt; 
  &lt;/div&gt;
  &lt;center&gt;
  &lt;br/&gt;
  &lt;form name="register" id="register" &gt;
      &lt;table&gt;
          &lt;tr&gt;
          &lt;td&gt; UserName &lt;/td&gt;
              &lt;td&gt; &lt;input type="text" id="user" /&gt; &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt; Password &lt;/td&gt;
              &lt;td&gt; &lt;input type="password" name="password" id="password"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
      &lt;button onclick="check()"&gt; Submit &lt;/button&gt;
  &lt;/form&gt;
  &lt;a href="Home page.html"&gt; Go to Home page &lt;/a&gt;
  &lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>