计算输入的字符数
2006-11-10 22:03
225 查看
计算输入的字符数
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="ProgId" content="FrontPage.Editor.Document">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title>测试字符所占字节数</title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<script language="javascript">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
function isChinese(str)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var lst = /[u00-uFF]/;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return !lst.test(str);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
var strtest="This测试!";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
var strlength=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
for (i=0;i<strtest.length;i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (isChinese(strtest.charAt(i))==true)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
strlength=strlength + 2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
strlength=strlength + 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
alert(isChinese(strtest.charAt(i)));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
alert(strlength);
![](http://images.csdn.net/syntaxh<br/>a487<br/>ighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="ProgId" content="FrontPage.Editor.Document">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title>测试字符所占字节数</title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<script language="javascript">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
function isChinese(str)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var lst = /[u00-uFF]/;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return !lst.test(str);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
var strtest="This测试!";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
var strlength=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
for (i=0;i<strtest.length;i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (isChinese(strtest.charAt(i))==true)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
strlength=strlength + 2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
strlength=strlength + 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
alert(isChinese(strtest.charAt(i)));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
alert(strlength);
![](http://images.csdn.net/syntaxh<br/>a487<br/>ighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- 华为2012.09.03浙大机试题 去掉字符串中的重复字符,字符串中重复字符的压缩,根据输入计算字符串结果
- 如何用javascript计算文本框还能输入多少个字符
- UITextField 计算输入的字符个数(包含中英文数字特殊符号)
- jQuery计算文本宽度和input标签根据输入字符动态自适应宽度的实现
- C和指针待完事项【计算标准输入单词“the”出现的次数,输入的单词由一个或多个空白字符分离。】
- 输入一串字符串,运用输出方法计算其中大写 小写 数字 和其他字符的个数
- 请用户输入一个字符串,计算字符串中的字符个数,并输出。
- 华为机试: 计算字符串的相似度、输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 华为计算字符个数写出一个程序,接受一个有字母和数字以及空格组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。
- 计算用户已经输入多少个字符
- C 语言 输入字符串 并计算输入的字符的长度
- js计算文本框输入的字符数
- js jquery实时计算输入字符
- 计算输入文本框的字符数量
- 键盘输入若干字符,计算其中的字母个数,空格个数,数字个数,及其他字符的个数。
- js计算当前输入的个数,汉字算两个字符
- Javascript在ASP.NET中的用法:计算还剩余输入多少个字符
- android 输入框 实时计算剩余的输入字符数(addTextChangedListener)
- C语言中字符的输入输出以及计算字符个数的方法详解
- 用户控件--控制一个文本框只允许输入固定多个字符(按照字节计算)