In my textfield it should allow both positive and negative decimal values. So I used the regex
#define FLOAT_REGEX @"-[0-9]+(\.[0-9][0-9]?)?"
-(BOOL) checkForDecimalValue:(NSString *) string
{
NSPredicate *confidenceTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",FLOAT_REGEX];
return [confidenceTest evaluateWithObject:string]?YES:NO;
}
But it is not accepted if I enter only positive values without any decimal point (for ex 100,200, etc). It should allow positive values and integer also.
replace the line use the following:
Hope this helps in what you want. Check its validity from here