實(shí)現(xiàn)函數(shù):
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 "";
}
檢查函數(shù):
function ischinese(s)
{
var errorChar;
var badChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789><,[]{}?/+=|\\'\":;~!#$%()`";
errorChar = isCharsInBag( s, badChar)
if (errorChar != "" )
{
report=report+"請(qǐng)重新輸入中文\n";
return false;
}
return true;
}
就這么簡(jiǎn)單:)其實(shí)還輸入日語(yǔ),暈