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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:14:25+00:00 2026-05-25T03:14:25+00:00

Possible Duplicate: iPhone SDK: Set Max Character length TextField I have 5 UITextFields, where

  • 0

Possible Duplicate:
iPhone SDK: Set Max Character length TextField

I have 5 UITextFields, where only 6 characters should be allowed. How can I limit the input to just 6 characters per text field? Any other code I tried failed and I didn’t found a way of fixing it, thanks 😀
EDIT: This is the codes I tested:

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    NSUInteger newLength1 = [serie1.text length] + [string length] - range.length;
    NSUInteger newLength2 = [serie2.text length] + [string length] - range.length;
    NSUInteger newLength3 = [serie3.text length] + [string length] - range.length;
    NSUInteger newLength4 = [serie4.text length] + [string length] - range.length;
    NSUInteger newLength5 = [serie5.text length] + [string length] - range.length;

    if(newLength1 > 6)
        return NO;
    if(newLength2 > 6)
        return NO; 
    if(newLength3 > 6)
        return NO; 
    if(newLength4 > 6)
        return NO; 
    if(newLength5 > 6)
        return NO;

    return YES;
}

and

-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if(serie1.text.length >= 6 && range.length == 0) {
        return NO;

    }
    if(serie2.text.length >= 6 && range.length == 0) {
        return NO;

    }
    if(serie3.text.length >= 6 && range.length == 0) {
        return NO;

    }
    if(serie4.text.length >= 6 && range.length == 0) {
        return NO;

    }
    if(serie5.text.length >= 6 && range.length == 0) {
        return NO;

    }
    return YES;
}

Both have the problem that when you write 6 characters then you cannot write anymore on any other text field until you delete the characters you wrote

  • 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-25T03:14:25+00:00Added an answer on May 25, 2026 at 3:14 am
    -(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
    {
       if(textField.text.length >= 7 && range.length == 0)  
       {
          return NO;
       }
       return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Uploading and downloading via ftp with iPhone SDK I want to implement
Possible Duplicate: Install xCode 3.2.3 w/ iPhone SDK 4, get “Base SDK missing”, can't
Possible Duplicate: How to Check for an active Internet Connection on iPhone SDK? How
Possible Duplicate: How do you implement a good profanity filter? I have an iPhone
Possible Duplicate: Is there an iPhone SDK API for twitter? i need to post
Possible Duplicate: How to check for an active Internet Connection on iPhone SDK? I
Possible Duplicate: Iphone sdk support for playing mp3 files over the network I need
Possible Duplicate: Push-Notification Badge auto increment. I have implemented Push Notification for my iPhone
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have

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.