标签:ios
//判断是否为整形:
- (BOOL)isPureInt:(NSString*)string{
NSScanner* scan = [NSScanner scannerWithString:string];
int val;
return[scan scanInt:&val] && [scan isAtEnd];
}
//判断是否为浮点形:
- (BOOL)isPureFloat:(NSString*)string{
NSScanner* scan = [NSScanner scannerWithString:string];
float val;
return[scan scanFloat:&val] && [scan isAtEnd];
}
if( ![self isPureInt:textField.text] || ![self isPureFloat:textField.text]){
textField.textColor = [UIColor redColor];
textField.text = @"警告:含非法字符,请输入纯数字!";
return;
}else{
textField.textColor = [UIColor blackColor];
if ([textField.text integerValue]>self.moneyT) {
[SMAlertView showAlert:[NSString stringWithFormat:@"退款金额不能超过钱袋的总金额%ld,请重新输入",(long)self.moneyT]];
textField.text=nil;
}else{
self.money = textField.text;
}
}
标签:ios
原文地址:http://blog.csdn.net/darongzi1314/article/details/44751743