Email validation custom method :
-(BOOL) validEmailAddress:(NSString*) emailString {
NSString *regExPattern = @"^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$";
NSRegularExpression *regEx = [[NSRegularExpression alloc] initWithPattern:regExPattern options:NSRegularExpressionCaseInsensitive error:nil];
NSUInteger regExMatches = [regEx numberOfMatchesInString:emailString options:0 range:NSMakeRange(0, [emailString length])];
if (regExMatches == 0)
return NO; // email invalid
else
return YES; // email valid
}
Now, just call above method from where you want to validate email address (pass your email address as a emailString to this method).
For eg:
-(BOOL) validEmailAddress:(NSString*) emailString {
NSString *regExPattern = @"^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$";
NSRegularExpression *regEx = [[NSRegularExpression alloc] initWithPattern:regExPattern options:NSRegularExpressionCaseInsensitive error:nil];
NSUInteger regExMatches = [regEx numberOfMatchesInString:emailString options:0 range:NSMakeRange(0, [emailString length])];
if (regExMatches == 0)
return NO; // email invalid
else
return YES; // email valid
}
Now, just call above method from where you want to validate email address (pass your email address as a emailString to this method).
For eg:
if ([self validEmailAddress:yourEmailAddressText] == YES) {
//email valid
}
else {
//email invalid
}
I need to validate email id in a way that it should accept only gmail and gtalk ids and other than that i need to show warning
ReplyDelete....@test.com check this email
ReplyDeleteTired of hearing about how much we love remote working? Take it from some others! Rounded up below are 27 Quotes on Remote Work and flexible lifestyles from some major power players.
ReplyDelete700 pages printed manual available for comprehensive courses
ReplyDelete24 x 7 access from anywhere for online courses
Experts in HIPAA Privacy Officer Training and HIPAA Security Officer Training with more than 18+ years experience
The information shared about ios app development is of top quality which has to get appreciated at all levels.
ReplyDelete