How to disable default return key on UIKeyboardTypeDefault for UITextfiled when Text length is <=4

168 Views Asked by At

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.

1

There are 1 best solutions below

3
On

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!!