用户注册 验证邮箱格式是否正确

12345678910111213141516
 
      
-(BOOL)CheckInput:(NSString *)_text
{
NSString *Regex=@"[A-Z0-9a-z._%+-]+@[A-Z0-9a-z._]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest=[NSPredicate predicateWithFormat:@"SELF MATCHES %@",Regex];
return [emailTest evaluateWithObject:_text];
}
 
 
- (IBAction)getbackPasswd:(id)sender
{
if(![self CheckInput:signemailTextField.text]){
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"您的邮箱格式不正确,请检查" delegate:self cancelButtonTitle:@"返回" otherButtonTitles:nil, nil];
[alert show];
}
}

你可能感兴趣的:(ios)