title: Count textarea characters
body: <p>I am developing a character count for my textarea on this <a href="http://ilanshomekitchen.x10.mx/new/contact.html">website</a>. Right now, it says NaN because it seems to not find the length of how many characters are in the field, which at the beginning is 0, so the number should be 500. In the console in chrome developer tools, no error occur. All of my code is on the site, I even tried to use jQuery an regular JavaScript for the character count for the textarea field, but nothing seems to work.</p>
  
  <p>Please tell me what I am doing wrong in both the jQuery and the JavaScript code I have in my contact.js file.</p>
  
  <pre><code>$(document).ready(function() {
      var tel1 = document.forms["form"].elements.tel1;
      var tel2 = document.forms["form"].elements.tel2;
      var textarea = document.forms["form"].elements.textarea;
      var clock = document.getElementById("clock");
      var count = document.getElementById("count");
  
      tel1.addEventListener("keyup", function (e){
          checkTel(tel1.value, tel2);
      });
  
      tel2.addEventListener("keyup", function (e){
          checkTel(tel2.value, tel3);
      });
  
      /*$("#textarea").keyup(function(){
          var length = textarea.length;
          console.log(length);
          var charactersLeft = 500 - length;
          console.log(charactersLeft);
          count.innerHTML = "Characters left: " + charactersLeft;
          console.log("Characters left: " + charactersLeft);
      });â€‹*/
  
      textarea.addEventListener("keypress", textareaLengthCheck(textarea), false);
  });
  
  function checkTel(input, nextField) {
      if (input.length == 3) {
          nextField.focus();
      } else if (input.length &gt; 0) {
          clock.style.display = "block";
      } 
  }
  
  function textareaLengthCheck(textarea) {
      var length = textarea.length;
      var charactersLeft = 500 - length;
      count.innerHTML = "Characters left: " + charactersLeft;
  }
  </code></pre>