title: Textarea value count length jquery
body: <p>I think i'm missing something or have a silly error. I'm trying to get the counter going for textarea &amp; for some reason length of textarea value is always zero. Here is my same code for View:</p>
  
  <pre><code>@Html.TextAreaFor(x =&gt; x.Description, new { @maxlength = "4000", @onkeyup = "countChar(this)" })
  @Html.Label("", " ", new { @id = "lblcount" })
  </code></pre>
  
  <p>my corresponding javascript is:</p>
  
  <pre><code>function countChar(val) {
      var max = 4000;
      var len = $("#txtDescription").val().length;
      if (len &gt;= max) {
          $('#lblcount').text(' you have reached the limit');
          $('#lblcount').attr("class", "lblCountRed");
      } else {
          var ch = max - len;
          $('#lblcount').text(ch + ' characters left');
          $('#lblcount').attr("class", "lblCountGreen");
      }
  };
  </code></pre>
  
  <p>The above code always sets label text to "4000 characters left" irrespective of number of characters I type inside textarea.</p>