+ Reply to Thread
Results 1 to 2 of 2

Thread: Email check for valid or not

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    7

    Email check for valid or not

    hi
    i have a UITextField that is taking Email as input. i want to check validity of email, mean Email format is valid or not just like PHP regular expression i have searched a lot but haven't find any solution for iOS.
    please suggest me any tutorial link or any code snippet.

  2. #2
    Junior Member
    Join Date
    Oct 2012
    Posts
    12
    simple solution is
    Code:
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; 
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; 
    NSString *strEmail = [txtLoginUser.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    BOOL res = [emailTest evaluateWithObject:strEmail];
    using res BOOL, you can decide valid or not valid format. if True, entered email is valid.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts