Wednesday, 20 June 2012

UITextField Email Validater code iPhone

- (void) Register: (id) sender{
NSString *eml=textEmail.text; /// email textfield
NSString *regex = @"\\b([a-zA-Z0-9%_.+\\-]+)@([a-zA-Z0-9.\\-]+?\\.[a-zA-Z]{2,6})\\b";
NSPredicate * regextest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
BOOL x= [regextest evaluateWithObject:eml];
if (x==FALSE) {
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Errror!" message:@"You have entered incorrect email ID" delegate:self cancelButtonTitle:@"Wanna Correct" otherButtonTitles:nil];
[alert show];
[textEmail becomeFirstResponder]; /// email textfield
[alert release];
}

1 comment: