I have UITexfields i want that it should accept only number other shows alert that enter a numeric value. I want that motionSicknessTextFiled should only accept number
this is the function which checks for the String contains Numeric value only
+(BOOL) checkforNumeric:(NSString*) str
{
NSString *strMatchstring=@"\\b([0-9%_.+\\-]+)\\b";
NSPredicate *textpredicate=[NSPredicate predicateWithFormat:@"SELF MATCHES %@", strMatchstring];
if(![textpredicate evaluateWithObject:str])
{
//////NSLog(@"Invalid email address found");
UIAlertView *objAlert = [[UIAlertView alloc] initWithTitle:APP_NAME message:@"please enter valid text." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Close",nil];
[objAlert show];
[objAlert release];
return FALSE;
}
return TRUE;
}
check it on submit button.