title: javascript text validation
body: <p>what am I doing wrong with this code?  I am trying to check the length, to make sure it is between 3 and 5 characters.</p>
  
  <pre><code>    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;form name = "form1" id="form1"&gt;
  &lt;input type="text" name="text1" id="text1" value="" onblur="testText(3,5)" /&gt;
  &lt;/form&gt;
  
  &lt;script type="text/javascript"&gt;
  function testText(minNum,maxNum){
      var str = document.form1.text1.value.length;
      if(str &gt;= minNum &amp;&amp; str &lt;= maxNum){
          alert('valid');
      }else{
          ALERT('ERROR: \N REQUIRED LENGTH IS AT LEAST' + minNum);
          document.form1.text1.focus();
      }
  }
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>