0

How to disable default return key on UIKeyboardTypeDefault for UITextField when text length is <=4?

Can any one help me on this? Thanks in advance.

Unheilig
  • 15,690
  • 193
  • 65
  • 96

1 Answers1

1

Try to implement this code Snippet:

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField.text.length <= 4)
    {
        return NO;
    }
    else
    {
        return YES;
    }
}

and be sure that you have set the delegate of Textfield to self

yourTextFeild.delegate = self;

hope this works!!

Sahil Mahajan
  • 3,786
  • 2
  • 26
  • 42