How to stop entering value in UITextField if the length is greater then 20 char.
Programmatically.
How to stop entering value in UITextField if the length is greater then 20 char.
Programmatically.
try this
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
//Set tag for a textfield
if(textField.tag==10)
{
NSUInteger newLength = [textField.text length] + [string length] - range.length;
return (newLength > 20) ? NO : YES;
}
}