title: Getting the length of a textbox value or content using JavaScript
body: <p>This is something that's driving me nuts:</p>
  
  <p>I have this code and it works: I am trying to learn JavaScript before becoming addicted to JQuery. My sample project involves getting the value of the text-box, and validating according to it's length. the name of the form is <strong><em>membership</em></strong>.</p>
  
  <p><em><strong>Example: This works:</em></strong></p>
  
  <pre><code>function validateForm()
  {
      var element = document.membership;
  
      if(element.txtName.value == "")
      {
          element.txtName.className = "alert";
      }
      else
      {
          element.txtName.className = "";
      }
  }
  </code></pre>
  
  <p><em><strong>But this doesn't:</em></strong></p>
  
  <pre><code>function validateForm()
  {
      var element = document.membership;
      var nameLenght = element.txtName.value.lenght;
  
      if(nameLenght &lt; 1)
      {
          element.txtName.className = "alert";
      }
      else
      {
          element.txtName.className = "";
      }
  }
  </code></pre>
  
  <p>Just an FYI: I am new to JavaScript but very familiar with the syntax. I just want to learn the basics and move up.</p>
  
  <p>I even read some solutions on here but feel I am simply sinking deeper.</p>
  
  <p>Thanks for your help.</p>