<script src=”Scripts/jquery.textareacounter.js” type=”text/javascript”></script>
页面结构代码:
<form id=”form1″ runat=”server”>
<div align=”center”>
<fieldset style=”width: 400px; height: 250px”>
<table cellpadding=”3″ cellspacing=”3″ border=”0″>
<tr>
<td>
<b>请输入您的评价:</b>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID=”txtCmt” runat=”server” TextMode=”MultiLine” Width=”300px” Rows=”5″></asp:TextBox>
</td>
</tr>
</table>
</fieldset>
</div>
</form>
调用插件实现文本框控件txtCmt的字符限制功能,脚本代码:
<script type=”text/javascript”>
$(document).ready(function () {
$(“#txtCmt”).textAreaCount({ maxlength: 200, speed: 256 });
});
</script>
注:要使用该插件,调用textAreaCount()方法即可,可以设置该方法的options参数,
options参数说明:
maxlength:设置最大输入字符数量
speed:设置截取字符的速度
msgstyle:设置文本提示信息主题的样式
msgNumStyle:设置文本提示信息里剩余字符数量的样式
最终使用该插件后的效果图:











