Question

On the Sign Up in my app I want to make sure that the user fill in one field. It should not matter which field for the user though. That's the problem I'm having. The closet I get is to force the user to fill in one specific textfield like the code below. And that's not the best UX i guess :) Anyone who know what to do?

 self.saveButton.delegate = self;


- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if ([self.RandomTextField.text isEqualToString:@""]) {
        self.saveButton.enabled = NO;
    } else {
        self.saveButton.enabled = YES;
    }
    return YES;
}
Was it helpful?

Solution

- (IBAction)SignUPBtn:(UIButton *)sender {

   if(txtName.text.length==0 && txtEmail.text.length==0 && txtPass.text.length==0)
   {
         [[[UIAlertView alloc] initWithTitle:@"" message:@"Please Fill Atleast One Field" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]show];

   }
   else
   {
      //Write Your Code here. this else called only if anyone of three textfield is filled up.

   }
}

OTHER TIPS

in the click event of the sign_up button

- (IBAction)SignUPBtn:(UIButton *)sender {
      if([textfeld_Email.text length]>0)
    {
        //sign up
    }
    else
    {
        if([textfeld_Pswd.text length]>0)
        {
         //sing up   
        }

        else{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Please enter your email and pass" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];

        }
    }  


}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top