title: Specifying maxlength for multiline textbox
body: <p>I'm trying to use asp:</p>
  
  <pre><code>&lt;asp:TextBox ID="txtInput" runat="server" TextMode="MultiLine"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>I want a way to specify the <code>maxlength</code> property, but apparently there's no way possible for a <code>multiline textbox</code>. I've been trying to use some JavaScript for the <code>onkeypress</code> event: </p>
  
  <pre><code>onkeypress="return textboxMultilineMaxNumber(this,maxlength)"
  
  function textboxMultilineMaxNumber(txt, maxLen) {
      try {
          if (txt.value.length &gt; (maxLen - 1)) return false;
      } catch (e) { }
      return true;
  }
  </code></pre>
  
  <p>While working fine the problem with this JavaScript function is that after writing characters it doesn't allow you to delete and substitute any of them, that behavior is not desired.</p>
  
  <p>Have you got any idea what could I possibly change in the above code to avoid that or any other ways to get round it?</p>