JS统计还可以输入多少字数
2014-05-27 09:44
148 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="../../api/jquery/jquery-1.5.2.min.js"></script>
<SCRIPT language="javascript">
function txtanum() //统计txta的输入字数
{
var maxl = 81;
var num = 80;
var content = $("#txtContent").val();
content.slice(0, maxl);
var nowlength = content.length;
if (nowlength >= 0) {
if (nowlength < num) {
$("#spid").text(num - nowlength);
} else {
$("#spid").text(0);
}
} else {
$("#txtContent").val(content.substring(0, maxl - 1));
}
if (nowlength == 0) {
$("#spid").text(num);
}
if (nowlength > num) {
$("#txtContent").val(content.substring(0, num))
}
}
</script>
</head>
<body> 你还可以输入<span id="spid">80</span>字</div>
<textarea id="txtContent" onkeypress="" class="zhongj_sou_as" tabindex="3" name="txtContent" onkeyup="txtanum()"
runat="server"></textarea></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="../../api/jquery/jquery-1.5.2.min.js"></script>
<SCRIPT language="javascript">
function txtanum() //统计txta的输入字数
{
var maxl = 81;
var num = 80;
var content = $("#txtContent").val();
content.slice(0, maxl);
var nowlength = content.length;
if (nowlength >= 0) {
if (nowlength < num) {
$("#spid").text(num - nowlength);
} else {
$("#spid").text(0);
}
} else {
$("#txtContent").val(content.substring(0, maxl - 1));
}
if (nowlength == 0) {
$("#spid").text(num);
}
if (nowlength > num) {
$("#txtContent").val(content.substring(0, num))
}
}
</script>
</head>
<body> 你还可以输入<span id="spid">80</span>字</div>
<textarea id="txtContent" onkeypress="" class="zhongj_sou_as" tabindex="3" name="txtContent" onkeyup="txtanum()"
runat="server"></textarea></div>
</body>
</html>
相关文章推荐
- JS统计还可以输入多少字数
- JS统计还可以输入多少字数,用于向输入者提示信息
- js动态显示可输入字数并提示还可以输入的字数
- 显示文本框还可以输入多少字数
- JS动态呈现还可以输入字数
- js统计当前输入字数在指定的输入区域显示
- JS与jQuery判断文本框还剩多少字符可以输入的方法
- js统计文本框还能输入多少字
- FCKeditor利用js插入图片以及统计当前输入字数方法
- JS统计可输入剩余字数,用于向输入者提示信息
- js校验输入框还可以输入多少个字,区分汉字和非汉字
- js统计文本框剩余可输入字数 中文 英文长度区分
- js统计文本框内已输入字数
- js限制字符的输入的数量(并提示还可输入多少字符)
- FCK常用Js,获取FCK内容,统计FCK字数,向FCK写入指定代码
- 输入一句话,统计共有多少单词
- 在开始里的运行中,我们可以输入中多少命令,分别代表什么。
- JS 输入字数判断实现代码
- php jquery ajax无刷新评论 无刷新翻页,字数统计 绝对可以用
- JS统计字数