iOS E-Mail Validation

iOS E-Mail Validation

(BOOL) NSStringIsValidEmail:(NSString *)emailString

{

 

    BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/

    NSString *stricterFilterString = @”^[A-Z0-9a-z._%+-][email protected]([A-Za-z0-9-]+.)+[A-Za-z]{2,4}$”;    NSString *laxString = @”^[email protected]([A-Za-z0-9-]+.)+[A-Za-z]{2}[A-Za-z]*$”;

    NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;

    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@”SELF MATCHES %@”, emailRegex];

    return [emailTest evaluateWithObject:emailString];

}

Yorum Yap
0 Yorum yapan