Question: I have a `UITextField`, I'd like to restrict the maximum allowed input value in the field to be 1000. That's when user is inputting number inside, once the input value is larger than 999, the value in input field won't be updated anymore unless user is inputting value less than 1000. 

I think I should use `UITextField` delegate to limit the input:

```
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
  //How to do
}

```

But I am not sure how to implement it. Any suggestions?

**==========Update=============**

my input field not only allow user to input integer, but also float value like 999,03

Answer: 
```
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if(textField.tag == 3)
    {
        if(textField.text.length >3 && range.length == 0)
        {
            return NO;
        }
        else
        {
            return YES;
        }
    }
}

```
```
if([string length])
{
  if (textField == txt)
  {
      NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
      return !([newString length] > 1000);
  }                     
}

```