title: Maxlength check using JQuery For multiline text box
body: <pre><code>&lt;asp:TextBox ID="txtPurpose" CssClass="dd" runat="server" MaxLength="500" OnKeyUp="return maxlength();" OnPaste="return maxlength();" TextMode="MultiLine"
                                  Width="70%" Rows="4" ValidationGroup="tool"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>in javascript</p>
  
  <pre><code>function maxlength()
          {
  
              var max = 500;
              if ($('.dd').focus().val().length &gt; max)
              {
                  $('.dd').val($('.dd').val().substr(0, max));
              }
              $('.charsRemaining').html('You have ' + (max - $('.dd').val().length) + ' characters remaining');
          }
  </code></pre>
  
  <p>it is working fine but when copying something and pasting it in textarea using mouse right click $('.dd').focus().val() is coming as empty string. what to do </p>