限制只能中文输入的方法

2016-01-29 17:31 5 1 收藏

限制只能中文输入的方法,限制只能中文输入的方法

【 tulaoshi.com - ASP 】

  实现函数:
function isCharsInBag (s, bag)
{
var i,c;
for (i = 0; i < s.length; i++)
{
c = s.charAt(i);//字符串s中的字符
if (bag.indexOf(c) -1)
return c;
}
return "";
}
检查函数:
function ischinese(s)
{
var errorChar;
var badChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789<,[]{}?/+=|'":;~!#$%()`";
errorChar = isCharsInBag( s, badChar)
if (errorChar != "" )
{
report=report+"请重新输入中文n";
return false;
}

return true;
}
就这么简单:)其实还输入日语,晕

 

来源:https://www.tulaoshi.com/n/20160129/1501733.html

延伸阅读
bluestacks怎么输入中文?   bluestacks里面有集成中文输入法的,具体使用方式为:点击输入框,选择谷歌输入法,然后再次输入就可以了。
标签: SQLServer
A. SQL Server has no built-in tools/facilities to do this. It also does not have the facility to run a stored-procedure on connection that could be written/used to do this. Therefore you have the following choices :- SQL Server没有这样的功能,也没有提供在连接时执行某一特定过程的功能。这里介绍几种实现的方法 1. Put ...
标签: 电脑入门
笔记本电脑上安装的 word 2007 里的输入法只能打英文,不能输入中文。使用 ctrl + space 或者 ctrl + shift 也无法切换出中文输入法。 一翻研究,发现是word 2007 的设置问题,解决方法如下: 1. 打开一个 word 文本,选中左上角的圆圈,点击 word 选项 2. 选项打开之后,选择高级,然后把输入法处于活动状态的钩钩去掉
标签: Web开发
-------------------------------  onkeypress="if (event.keyCode 45 || event.keyCode 57) event.returnValue = false;" ------------------------------- 在文本框的 onkeypress事件中加入以上代码,屏蔽键盘事件中,输入值不是数字则返回为false
我们在使用WORD的时可能会经常碰到WORD中无法输入中文的情况。因为,虽然我们安装了搜狗输入法,但是到我们在WORD中使用搜狗的输入法的切换中英文的按键的时候会发现根本没有效果,无法将输入法切换成中文的。下面我就介绍一下如何在WORD中把搜狗输入法切换到中文。 在word2010或2003中搜狗输入法无法切换中文怎么解决? 我装的是office2010...

经验教程

241

收藏

6
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部