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 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

Related Questions

I am using standard windows forms controls under C#. I have two controls which
I'd like to check ancestry using two jQuery objects. They don't have IDs, and
I'm using two different libraries in my project, and both of them supply a
I'm using two commercial libraries that are produced by the same vendor, called VendorLibA
For some reason, when using two sums on a group by, i run into
I'm slowly building my application to a working state. I'm using two functions called
Has anyone had experience using these two technologies in tandem? What are (if any)
I wish to know all the pros and cons about using these two methods.
Using extension syntax I'm trying to create a left-join using LINQ on two lists
Using Firebird, I want to combine the results of two queries using UNION ALL,

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.