"Check if email is valid"

Tue 19 May 2009

#import "GTMRegex.h"

 

//Check if email is valid

//You need to include attached files into your project 

//We are using regular expressions in this method

-(BOOL)isEmailValid:(NSString *)email {

BOOL isValid = YES;

NSString *emailRegEx = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";

GTMRegex *regex = [GTMRegex regexWithPattern:emailRegEx];

if(([regex matchesString:email]) == YES){

NSLog(@"Registration Form: You have entered valid email address %@", email); 

}

else {

NSLog(@"Registration Form: You have entered INVALID email address %@", email); 

isValid = NO;

}

return isValid;

}


Archive.zip (15.13 kb)