实现函数:
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;
}
就这么简单:)其实还输入日语,晕
|