我正在输入值 textfiled 我希望如果它是正确的值那么它可以显示警报并使文本字段为空。所以用户可以输入正确的值我已经尝试了很多方法但我没有解决它。
-(void)textFieldTextDidChangeClinicMarkup:(UITextField*)tf{
NSString*test=clinicMarkupTextField.text;
if([test isEqualToString:@"1"]){
NSString*value=@"1";
appDelegate.clinicalMarkup=value;
}
else if([test isEqualToString:@"1.5"]){
NSString*value=@"1.5";
appDelegate.clinicalMarkup=value;
}
else if([test isEqualToString:@"2"]){
NSString*value=@"2";
appDelegate.clinicalMarkup=value;
}
else if([test isEqualToString:@"2.5"]){
NSString*value=@"2.5";
appDelegate.clinicalMarkup=value;
}
else if([test isEqualToString:@"3"]){
NSString*value=@"3";
appDelegate.clinicalMarkup=value;
}
else if([test length] >=3 || [test floatValue] > 3 || [test floatValue] <1 ) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Clinic Markup can only be 1, 1.5, 2, 2.5 and 3 " delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}