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;
}