As i am new to ios.I know this question has been asked before. but i am having difficulty among those. i want to validate email and password, when user enter correct email and password(8 to 10 character having regular expression) then button will enable and can go to next page. but if email and password is not correct then button will be disabled. as i have tried this but it will work when user click on button.
-(IBAction)clickOn:(id)sender
{
NSString *emailReg = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailReg];
if([emailTest evaluateWithObject:email.text] == NO)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"enter the Valid Mail id" message:@"Please Enter Valid Email Address." delegate:nil cancelButtonTitle:@"okay" otherButtonTitles:nil];
[alert show];
}
HomePage *home=[[HomePage alloc]initWithNibName:@"HomePage" bundle:nil];
[self.navigationController pushViewController:home animated:YES];
}
as i have taken textfied as like this
IBOutlet UITextField *email;
IBOutlet UITextField *pwd;
But i don't know how to attach textfield with method and how to disable button while validating email and password and enable them when both are perfect.