function isCharsInBag (s bag) { var ic; for (i = ; i < slength; i++) { c = scharAt(i);//字符串s中的字符 if (bagindexOf(c) > ) return c; } return ""; } 检查函数: function ischinese(s) { var errorChar; var badChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz><[]{}?/+=|":;~!#$%()`"; errorChar = isCharsInBag( s badChar) if (errorChar != "" ) { report=report+"请重新输入中文n"; return false; } return true; } |