<input type="text" maxlength="80" size="80" value="" id="title" name="title"/><span id="msgcount">可以输入80个字符,可以试用ubb格式</span>
<script type="text/javascript">
$(function() {
$("#title").keyup(function() {
//定义最多输入数字
var $max =80;
//取得用户输入的字符的长度
var $length = $("#title").val().length;
if ($length >= $max) {
//判断是否超过最长数字
$("#msgcount").html("<font color=red>内容不能超过80字</font>");
}
else {
//没有超过就修改剩余字数
$("#msgcount").html("还可以输入<font color=red>"+($max - $length)+"</font>字符");
}
})
})
</script>