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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:59:01+00:00 2026-05-21T01:59:01+00:00

hi i am using a series of textfields in a row in my application

  • 0

hi
i am using a series of textfields in a row in my application and my requirement is the textfield should accept only one character.if a user enters second character no action should be performed.

i implemented the delegate method as below

 - (BOOL)textField:(UITextField *)textField 
              shouldChangeCharactersInRange:(NSRange)range 
              replacementString:(NSString *)string{

if ([cellTextField.text length]>=MAXLENGTH && range.length==0) {
    textField.text=[cellTextField.text substringToIndex:MAXLENGTH-1];
    return NO;
}
else {
    return YES;
}

but my requirement is not being filled using the above code.

my next requirement is if a user continues entering a second character, the character should be placed in the consecutive textField(imagine crossword or scramble application). please help me in both scenarios if possible else solution for first requirement is also thankful.

thank you,
dinakar

  • 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-21T01:59:02+00:00Added an answer on May 21, 2026 at 1:59 am

    The following code solved this for me.

    Make sure you check for the “\b” (Backspace escape character) so that the user can still erase.

    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
        if ([textField.text length] >= MAXLENGTH && ![string isEqualToString:@"\b"])
            return NO;
        return YES;
    }
    

    As far as your second requirement goes it’s really not too hard. Just add a few lines of code into the above if-statement:

    nextTextField.text = [nextTextField.text stringByAppendingString:string]; 
    

    This should add whatever text you just typed in to the end of your next text field. You might also want to change the way backspace is handled. Something like:

     if ([string isEqualToString:@"\b"])
        nextTextField.text = [nextTextField.text substringToIndex:[nextTextField.text length]-1];
    

    Adding that code inside the above if statement as well should allow you to delete the character at the end of the complete string (at the end of the string in the next text field).


    EDIT: Here’s the code I use to create the field.

    titleInput = [[UITextField alloc] initWithFrame:(CGRect){40,145,400,30}];
    titleInput.borderStyle = UITextBorderStyleRoundedRect;
    titleInput.delegate = self;
    [self addSubview:titleInput];
    

    Cheers

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

Sidebar

Related Questions

I'm trying to create a cube using one series of vertices such as attempted
Using series.add(180, 1); produces a perfectly valid chart like this (little red dot at
I have been trying to approximate e using series representation to get as many
Ok I am trying to show a number using a series of Images. eg.
I've set up some charts using highcharts, populating it's series column using the brilliant
Using the following simulated time series: n=70 m1 = matrix(rnorm(n), ncol=7) m2 = matrix(rnorm(n,
We're using a DataView to display a series of buttons. The data comes from
I'm making (time series) moutain chart using JFreeChart. So, i made 2 timeseries -
I am using flot to display a stacked time series in an mvc3 webpage.
I have a series of divs that slide down using -webkit-transform from a negative

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.