码迷,mamicode.com
首页 > 移动开发 > 详细

ios-邮箱正则表达式判断

时间:2014-09-04 16:34:39      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:des   style   color   os   io   ar   for   div   cti   

- (void)loadData {

     NSMutableArray *array = [NSMutableArray arrayWithCapacity:10];

    if ([self.title isEqualToString:@"名字"]) {

        self.nameStr = inputTextField.text;

    [array addObject:[NSDictionary dictionaryWithObject:self.nameStr forKey:@"memberNm"]];

    }else if ([self.title isEqualToString:@"邮箱"]){

        self.emailStr = inputTextField.text;

       BOOL emailOK= [self validateEmail:self.emailStr];

        if (!emailOK) {

            [UIAlertView showMessage:@"邮箱格式不正确" title:@"警告"];

            return;

        }

    [array addObject:[NSDictionary dictionaryWithObject:self.emailStr forKey:@"memberEmail"]];

    }else if([self.title isEqualToString:@"其它联系方式"]){

        self.otherStr = inputTextField.text;

      

    [array addObject:[NSDictionary dictionaryWithObject:self.otherStr forKey:@"memberContacts"]];

    }else if ([self.title isEqualToString:@"岗位分工"]){

        self.jobdivison = inputTextField.text;

        [array addObject:[NSDictionary dictionaryWithObject:self.jobdivison forKey:@"memberDesc"]];

    }

    self.request = [UPRequest postDataWithPathName:@"member/updateMember" delegate:self params:array];

}

 

 

//邮箱正则表达式判断

-(BOOL)validateEmail:(NSString *)email

{

    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:email];

}

ios-邮箱正则表达式判断

标签:des   style   color   os   io   ar   for   div   cti   

原文地址:http://www.cnblogs.com/xm5mao/p/3956136.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!