title: How to display a message for a few seconds and then disappear in javascript
body: <p>The following is a code snippet for successful username entry. It checks the value from the database and displays message accordingly. I want to display the else part only for a few seconds i.e. "Username successful" message should show and disappear.</p>
  
  <pre><code>if(xmlhttp.responseText==1)
  {
      document.getElementById("check").innerHTML="Username already exists";
  }
  else
  {
      document.getElementById("check").innerHTML="Username successfull";          
  }
  </code></pre>
  
  <p>The check class is as follows:</p>
  
  <pre><code>&lt;ul class="user"&gt;
      &lt;li class="label"&gt;User name &lt;/li&gt;
      &lt;li class="field"&gt;
          &lt;input type="text" id="username" name="username" class="required error" onchange="checkuser(this.value);"/&gt; 
         &lt;div class="check " id="check"/&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>