Password validation in UITextField in iOS

This is how I would do it. The validation should be done at the end when the user has typed in the password and not in between.I will not be using NSRegularExpression. -(void)textFieldDidEndEditing:(UITextField *)textField{ int numberofCharacters = 0; BOOL lowerCaseLetter,upperCaseLetter,digit,specialCharacter = 0; if([textField.text length] >= 10) { for (int i = 0; i < [textfield.text … Read more

How to know if a UITextField in iOS has blank spaces

You can “trim” the text, that is remove all the whitespace at the start and end. If all that’s left is an empty string, then only whitespace (or nothing) was entered. NSString *rawString = [textField text]; NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; NSString *trimmed = [rawString stringByTrimmingCharactersInSet:whitespace]; if ([trimmed length] == 0) { // Text was … Read more

How to know if a UITextField in iOS has blank spaces

You can “trim” the text, that is remove all the whitespace at the start and end. If all that’s left is an empty string, then only whitespace (or nothing) was entered. NSString *rawString = [textField text]; NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; NSString *trimmed = [rawString stringByTrimmingCharactersInSet:whitespace]; if ([trimmed length] == 0) { // Text was … Read more

Email validation on textField in iOS

Use NSPredicate and Regex: – (BOOL)validateEmailWithString:(NSString*)email { NSString *emailRegex = @”[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}”; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@”SELF MATCHES %@”, emailRegex]; return [emailTest evaluateWithObject:email]; } For a bunch of emails separated by a comma: – (NSMutableArray*)validateEmailWithString:(NSString*)emails { NSMutableArray *validEmails = [[NSMutableArray alloc] init]; NSArray *emailArray = [emails componentsSeparatedByString:@”,”]; for (NSString *email in emailArray) { NSString *emailRegex = … Read more

iphone bullet point list

The “bullet” character is at Unicode code point U+2022. You can use it in a string with @”\u2022″ or [NSString stringWithFormat:@”%C”, 0x2022]. The “line feed” character is at Unicode code point U+000A, and is used as UIKit’s newline character. You can use it in a string with @”\n”. For example, if you had an array … Read more

How to detect UIKeyboard “backspace” button touch on UITextField? [duplicate]

if the UITextField is empty, the shouldChangeTextInRange delegate method is not called You can subclass UITextField and override this method: -(void)deleteBackward; { [super deleteBackward]; NSLog(@”BackSpace Detected”); } since UITextField is compliant to the UITextInput protocol, this method is implemented, and you can override it to detect when backspace is pressed. Then, you can write your … Read more

Objective C: How to create a multi-line UITextField? [duplicate]

Check these answers: How to create a multiline UITextfield? How to create a multiline UITextfield? http://brettschumann.com/blog/2010/01/15/iphone-multiline-textbox-for-sms-style-chat And definitly try Three20 which is a great library used in many app like Facebook. Edit: Added extract from BrettSchumann blog #import <uikit uikit.h=””> @interface MultilineTextboxViewController : UIViewController { IBOutlet UIView *viewTable; IBOutlet UIView *viewForm; IBOutlet UITextView *chatBox; IBOutlet … Read more