- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
emailTextField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 150, 50)];
emailTextField.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:emailTextField];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(100, 170, 150, 50);
[button setTitle:@"注册" forState:UIControlStateNormal];
[button addTarget:self action:@selector(registor:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
- (void)registor:(UIButton *)button
{
if([self isValidateEmail:emailTextField.text]){
NSLog(@"邮箱格式正确");
}else {
NSLog(@"不是");
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"错误" message:@"请输入正确的邮箱" delegate:self cancelButtonTitle:@"好" otherButtonTitles:nil, nil];
[alert show];
}
}
判断邮箱格式是否正确
最新推荐文章于 2022-03-15 10:57:07 发布