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 522423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:21:09+00:00 2026-05-13T08:21:09+00:00

I have five fields for number input, and each of these fields must be

  • 0

I have five fields for number input, and each of these fields must be in a certain number range. For example, Field One should be above 40 and below 100. Field Two should be above 1.25 and below 5.5. You get the idea for the rest.

I am able to make an UIAlertView, but only for the button that is pressed to calculate each of the fields. If the end-user inputs wrong data for each of the five fields, they will then see five different Alerts and isn’t really UI friendly.

I would like to have it where the user inputs the number, and when the user goes to the next field, to evaluate their input and then send an Alert View. This way the user would automatically know before they input another field. I think this would work much easier for the UI. But, I don’t know the best way to do this and I’m just learning iPhone SDK and ObjC.

Here is my code I have used for my buttonPressed button, which as you can see takes each of the five (four in this case) fields, assigns them to a variable, creates two test UIAlerts, and does some math before outputting the answer. Keep in mind I’m a n00b here…..

//calculate total of variables when user clicks button
-(IBAction) submitYourName;
{
    /*********************************************************
     declare our variables to strings
     ********************************************************/
    NSString *userNameOne = txtUserName.text;
    float numOne = [userNameOne intValue];
    NSString *userNameTwo = txtUserName2.text;
    float numTwo = [userNameTwo intValue];
    NSString *userNameThree = txtUserName3.text;
    float numThree = [userNameThree intValue];
    NSString *userNameFour = txtUserName4.text;
    float numFour = [userNameFour intValue];

    /*********************************************************
     allow error handling for our numbers
     ********************************************************/
    if(numOne < 40 || numOne > 100)
    {
        UIAlertView *alert = [[UIAlertView alloc]
                              initWithTitle:@"User Error"
                              message:@"Your age must be at least 40 years old and less than 100 years old"
                              delegate:nil
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil];
        [alert show];
        [alert release];
    }

    if(numTwo < 40 || numTwo > 100)
    {
        UIAlertView *alert = [[UIAlertView alloc]
                              initWithTitle:@"User Error"
                              message:@"Your age must be at least 40 years old and less than 100 years old"
                              delegate:nil
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil];
        [alert show];
        [alert release];
    }


    /*********************************************************
     calculate our mathematics
     ********************************************************/
    float one = 3;
    float main = numOne * one;


    /*********************************************************
     produce answer
     ********************************************************/
    lblUserTypedName.text = [[NSString alloc] initWithFormat: @"you input %2.2f %2.2f %2.2f %2.2f", main, numTwo, numThree, numFour];
}
  • 1 1 Answer
  • 1 View
  • 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-13T08:21:09+00:00Added an answer on May 13, 2026 at 8:21 am

    I’d say invoke the UITextFieldDelegate’s :

    - (void)textFieldDidEndEditing:(UITextField *)textField;

    method, and in it check for the input validation.

    BTW, why would you display sooo many alerts? I’d suggest creating an NSString that would go through each if and add something like “Field 1’s input is not valid.” and so on, and in the end display one UIAlertView with all of the details.
    That would be user friendly and IMO better than your current solution.

    That’s just off the top of my mind, but I hope this would be of some help to you.
    ~ Natanavra.

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

Sidebar

Related Questions

I have five different websites set up using Wordpress 3.0 Multisite. They each contain
I have five html pages ,all pages have same search tab,header,footer, my question is
I have Five textboxes as part of a grid. <TextBox Name=A1 MaxLength=1 ></TextBox> <TextBox
I have the following locations table: ---------------------------------------------------------- | ID | zoneID | storeID |
There is a parameter in the Solr schema to set a default search field
I have attempted this is many ways but failed consistently, hopefully you can help
Here is what I want to do: I want to have a datagrid that
I recently started using Mercurial and like the way I have VCS protection for
** New EDIT ** so what I'm trying to do is this. I want
What function in Drupal gets file attachment path? Edit: the attachments provided by Upload

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.