First add delegate
and keyBoradType
of textField
textField.delegate=self;
textField.keyboardType = UIKeyboardTypeNumberPad;
Than have to use the textField.delegate
method like so -
- (BOOL) textField: (UITextField *)theTextField shouldChangeCharactersInRange:(NSRange)range replacementString: (NSString *)string
{
if (!string.length)
{
return YES;
}
if ([string intValue])
{
return YES;
}
return NO;
}