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

  • SEARCH
  • Home
  • 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 576497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:03:12+00:00 2026-05-13T14:03:12+00:00

I am using two forms of text validation (one when they click Next, another

  • 0

I am using two forms of text validation (one when they click Next, another when they manually select the next text field to enter) and it’s been working perfect. However, the last text field isn’t getting error checked and I can’t figure it out.

You can see the issue in this video on the last text field (http://screencast.com/t/ODJiOTAwMzA). The previous four work fine as you can see, but the bottom not so much.

Here is my code:

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == txtUserName)
    {
        NSString *userNameOne = txtUserName.text;
        double numOne = [userNameOne doubleValue];  

        if(numOne < 30 || numOne > 80)
        {

            //foo

            [txtUserName becomeFirstResponder];
            txtUserName.text = nil;
        }
        else 
        {
            [txtUserName2 becomeFirstResponder];
        }
    }

    else if (textField == txtUserName2)
    {

        NSString *userNameThree = txtUserName2.text;
        float numTwo = [userNameThree doubleValue]; 

        if (numTwo < 20 || numTwo > 32)
        {
            //foo

            [txtUserName2 becomeFirstResponder];
            txtUserName2.text = nil;
        }
        else
        {
            [txtUserName3 becomeFirstResponder];
        }
    }
    else if (textField == txtUserName3)
    {
        NSString *userNameThree = txtUserName3.text;
        float numThree = [userNameThree doubleValue];

        if (numThree < 475 || numThree > 650)
        {
            //foo

            [txtUserName3 becomeFirstResponder];
            txtUserName3.text = nil;
        }
        else
        {
            [txtUserName4 becomeFirstResponder];

        }
    }
    else if (textField == txtUserName4)
    {
        NSString *userNameFour = txtUserName4.text; 
        double numFour = [userNameFour doubleValue];

        if (numFour < 0.5 || numFour > 3.00)
        {

                        //foo

            [txtUserName4 becomeFirstResponder];
            txtUserName4.text = nil;
        }
        else
        {
            [txtUserName5 becomeFirstResponder];
        }
    }

    else if (textField == txtUserName5)
    {
        NSString *userNameFive = txtUserName5.text;
        double numFive = [userNameFive doubleValue];

        if (numFive > 1)
        {
                        //foo

        }
    }
    return NO;
}

and here

if (textField == txtUserName)
    {
        NSString *userNameOne = txtUserName.text;
        double numOne = [userNameOne doubleValue];  

        if(numOne < 30 || numOne > 80)
        {

                        //foo

            [txtUserName becomeFirstResponder];
            txtUserName.text = nil;
        }
        else 
        {
            [txtUserName2 becomeFirstResponder];
        }
    }

    else if (textField == txtUserName2)
    {

        NSString *userNameThree = txtUserName2.text;
        float numTwo = [userNameThree doubleValue]; 

        if (numTwo < 20 || numTwo > 32)
        {

                        //foo

            [txtUserName2 becomeFirstResponder];
            txtUserName2.text = nil;
        }
        else
        {
            [txtUserName3 becomeFirstResponder];
        }
    }
    else if (textField == txtUserName3)
    {
        NSString *userNameThree = txtUserName3.text;
        float numThree = [userNameThree doubleValue];

        if (numThree < 475 || numThree > 650)
        {
            //fo

            [txtUserName3 becomeFirstResponder];
            txtUserName3.text = nil;
        }
        else
        {
            [txtUserName4 becomeFirstResponder];

        }
    }
    else if (textField == txtUserName4)
    {
        NSString *userNameFour = txtUserName4.text; 
        double numFour = [userNameFour doubleValue];

        if (numFour < 0.5 || numFour > 3.00)
        {

            //foo

            [txtUserName4 becomeFirstResponder];
            txtUserName4.text = nil;
        }
        else
        {
            [txtUserName5 becomeFirstResponder];
        }
    }
    else if (textField == txtUserName5)
    {
        NSString *userNameFive = txtUserName5.text;
        double numFive = [userNameFive doubleValue];

        if (numFive > 1)
        {
            //foo
        }
        else
        {
            [txtUserName5 becomeFirstResponder];
        }
    }
  • 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-13T14:03:12+00:00Added an answer on May 13, 2026 at 2:03 pm

    If your interface is in Interface Builder, is the outlet for txtUserName5 hooked up?

    For your fifth text field, why don’t you have these lines after “foo” like you do for the other text fields?

    if (numFive > 1)
    {
        //foo
        [txtUserName5 becomeFirstResponder];
        txtUserName5.text = nil;
    }
    

    Also, for your else clause, rather than become first responder again, you should resign first responder (to dismiss the keyboard):

    else
    {
        //[txtUserName5 becomeFirstResponder];
        [txtUserName5 resignFirstResponder];
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 443k
  • Answers 443k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer after a lot of reading.. what i request may not… May 15, 2026 at 6:22 pm
  • Editorial Team
    Editorial Team added an answer According to man gitignore: DESCRIPTION A gitignore file specifies intentionally… May 15, 2026 at 6:21 pm
  • Editorial Team
    Editorial Team added an answer The following will load all desired lines of a file… May 15, 2026 at 6:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.