title: JavaScript form validation, string length
body: <p>I'm trying to do a formValidation for JavaScript, everything is working but I'm facing a problem now with the length. It actually works and give me the alert, but never pass it when I put 8 or more characters in the password field.</p>
  
  <p><strong>I'm sure there is a small mistake that I need to be aware of, please advice!</strong></p>
  
  <pre><code>if(!document.getElementById("username").value)
  {
      alert("Username field is required!");
      return false;
  
  }
  
  if(!document.getElementById("password").value)
  {
      alert("Password field is required!");
      return false;
  
  }
  
  if(!document.getElementById("password").length &lt; 8);
  {
      alert("Password should contain at least 8 characters!");
      return false;       
  }
  </code></pre>