javascript:
<mce:script language="javascript"><!-- function checkLength(which) { var maxChars = 20; if (which.value.length > maxChars) which.value = which.value.substring(0,maxChars); var curr = maxChars - which.value.length; document.getElementById("chLeft").innerHTML = curr.toString(); } // --></mce:script>
HTML:
<div> <asp:TextBox ID="txtInput" runat="server" Width="200px" Height="60px" onkeyup="checkLength(this);" TextMode="MultiLine"></asp:TextBox> <br /> <small>文字最大长度: 20. 还剩: <span id="chLeft">20</span>.</small> </div>