I am new to `iOS`,

I want to change keyboard after certain characters left in `UITextField`,

for e.g.: I have String of `@"AEBPQ1234M"`

for first 5 letters I want alphabet keyboard and then for next 4 letters I need number pad and on last letter I need again alphabet.

here is the code I have tried but it's not working when I hit backspace in the keyboard.

```
-(void)textFieldDidChange :(UITextField *)theTextField{
     if (theTextField.text.length < 5 || theTextField.text.length >= 9) {
    [theTextField setKeyboardType:UIKeyboardTypeEmailAddress];
}

if (theTextField.text.length >= 5 && theTextField.text.length < 9 ) {
    [theTextField setKeyboardType: UIKeyboardTypeNumberPad];
}

 [theTextField reloadInputViews];
}

```

Where I am making mistake?