+ Reply to Thread
Results 1 to 2 of 2

Thread: Email check for valid or not

  1. #1
    Junior Member
    Join Date
    Oct 2012

    Email check for valid or not

    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
    simple solution is
    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


Posting Permissions

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