title: Javascript Validating username Length
body: <p>I am trying to validate my username field and check if the username contains atleast 6 letters, if not then i show a pop up window indicating the same. 
  But the alert command does not seem to work.</p>
  
  <p>Following is the code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; Webpage &lt;/title&gt;
  &lt;/head&gt;
  &lt;script language="Javascript"&gt;
  function validate()
  {
  
  if (username1.length &lt; 6)
  {
  alert("Username must be atleast 6 charactrs long, Please Try Again");
  }
  
  }
  
  
  &lt;/script&gt;
  &lt;body&gt;
  &lt;form&gt;
  &lt;center&gt;
   &lt;fieldset&gt;
  &lt;table cellspacin="5" cellpadding="5" border="0"&gt;
  
  &lt;tr&gt;
  &lt;td&gt;Username: &lt;/td&gt;
  &lt;td align="left"&gt;&lt;input type=="text" name="username1" maxlength="20" size="20"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt; Password: &lt;/td&gt;
  &lt;td align = "left"&gt; &lt;input type="text" name="password" maxlength="20" size="20"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt; Please confirm your password: &lt;/td&gt;
  &lt;td align = "left"&gt; &lt;input type="text" name="password1" maxlength="20"        size="20"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td align="center"&gt;&lt;input type="submit" value="Log in" onClick="validate()"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/fieldset&gt;
  &lt;/table&gt;
  
  &lt;/center&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>