-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString *toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string]; if ([toBeString length] > 25) { textField.text = [toBeString substringToIndex:25]; return NO; } return YES; }