Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 736959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:39:53+00:00 2026-05-14T07:39:53+00:00

I have 3 UITextFields in a grouped UITableView and am trying to figure out

  • 0

I have 3 UITextFields in a grouped UITableView and am trying to figure out the correct logic to only have my ‘Save’ UIBarButtonItem enabled when none of the UITextFields are empty.

I’m currently using the - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string UITextField delegate method to detect changes to the field character by character, but it is providing inconsistent results.

Any ideas?

Edit: Here is the code I’m now using. As you can see I’ve placed my text fields into an array so I can iterate through them. As it is now, the save button doesn’t enable until I enter the 2nd character in the 3rd field. Also it alternates enabled/disabled as a remove characters one by one from the fields.

NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];

    BOOL allValid;

    if (newString.length)
    {
        // Cycle through array checking for completeness
        for (int i = 0; i < [textFieldArray count]; i++)
        {
            if ([[[textFieldArray objectAtIndex:i] text] length] > 0)
            {
                allValid = YES;
                NSLog(@"TextField #%i Validates.", i);
            }
            else
            {
                allValid = NO;
                NSLog(@"TextField #%i Does Not Validate.", i);
            }
        }
    }
    else
    {
        NSLog(@"Invalid");
        allValid = NO;
    }

    if (allValid)
        [saveButton setEnabled:YES];
    else
        [saveButton setEnabled:NO];

    return YES;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:39:54+00:00Added an answer on May 14, 2026 at 7:39 am

    Ok here’s how I finally did it.

    I created - (IBAction)validateFields:(id)sender and connected it to the Editing Changed outlet on UITextField. It looks like this.

    - (IBAction)validateFields:(id)sender
    {
        BOOL valid = YES;
    
        // On every press we're going to run through all the fields and get their length values. If any of them equal nil we will set our bool to NO.
        for (int i = 0; i < [textFieldArray count]; i++)
        {
            if (![[[textFieldArray objectAtIndex:i] text] length])
                valid = NO;
        }
    
        [saveButton setEnabled:valid];
    }
    

    I’ve given it a pretty decent go and couldn’t get the save button to enable on any combination of empty text fields so I’m going to say this is the way to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small form (5 fields) in a grouped UITableView. Each UITextField is
I have a grouped UITableViewController with one section and many rows. Each cell consists
I have several UITextFields that are in a group... I need to be able
Hello I have two UITextFields in my application, and want to dismiss the keyboard
in my view I have several UITextFields and I need to show some times
I have a table with 3 UITextFields added to the content views of cells
I have some xibs with all sorts of text controls (UITextFields, UITextViews). Since the
I've got a UITableView with some records shown, once a row is selected another
Is there a way for a UIButton to trigger resignFirstResponder? I have my program
I would to to do a 4 digit code entry like app does in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.