I implemented the following code. It is accepting any type of mail id’s. Example: abc@xyz.com. But I want to accept the perfect mail id’s.Example :abc@gmail.com,abc@yahoo.com. Can any one guide how to do this.
- (BOOL) validateEmail: (NSString *) candidate {
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:candidate];
}
Thanks in advance
Try out this code: