-(BOOL)judgeString {
//判断是否输入合法
BOOL success = true;
if (language==0) { //判断是否中文中含有英文
for(int i=0; i<self.context.text.length; i++) {
unichar commitChar = [self.context.text characterAtIndex:i];
if(((commitChar>64)&&(commitChar<91))||((commitChar>96)&&(commitChar<123))){
UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"警告" message:@"不能含有英文字符" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alter show];
success = false;
break;
}
}
} else { // 判断是否英文中含有中文
for(int i=0; i<self.context.text.length; i++) {
NSString *temp = [self.context.text substringWithRange:NSMakeRange(i,1)];
const char *commitChar = [temp UTF8String];
if(3==strlen(commitChar)){ //中文的字符长度都为3,英文的长度为1
UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"警告" message:@"不能含有中文字符" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alter show];
success = false;
break;
}
}
}
return success;
}
}