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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:53:53+00:00 2026-06-14T16:53:53+00:00

Possible Duplicate: Localized phone number formatting I am trying to make it to where

  • 0

Possible Duplicate:
Localized phone number formatting

I am trying to make it to where you type in a phone number and while typing, it realizes that there are so many characters and adds in parentheses: (xxx)xxx-xxxx. I have looked on Stack Overflow for any similar answers to my problem and I came along with this link.

However, I can’t use conversions to decimal form to solve my issue but have gained more knowledge in the fact that I probably should use textField:shouldChangeCharactersInRange:withString: method. I am also going to be needing to add in the hyphen as well in the phone number but figured if I can do it for one I can do it for the other.

Any suggestions?

  • 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-06-14T16:53:54+00:00Added an answer on June 14, 2026 at 4:53 pm

    How about this:

    -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
        if (textField.text.length == 0)
         textField.text = [NSString stringWithFormat:@"(%@",textField.text];
    
        if (textField.text.length == 4)
            textField.text = [NSString stringWithFormat:@"%@) ",textField.text];
    
        if (textField.text.length == 9)
            textField.text = [NSString stringWithFormat:@"%@-",textField.text];
    
        if (textField.text.length > 13)
            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: Is there some ninja trick to make a variable constant after its
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way
Possible Duplicate: Opening url in new tab while i am doing window.open(), my page
Possible Duplicate: Can a Bash script tell what directory it's stored in? Is there
Possible Duplicate: Learning to write a compiler I looked around trying to find out
Possible Duplicate: Reading through file using ifstream I'm trying to find a way to
Possible Duplicate: What is 0x10 in decimal? I notice that Console.WriteLine(18); writes 18, but
Possible Duplicate: nth-child for every two table rows I'm trying to work my way
Possible Duplicate: Schema for a multilanguage database I'm working on a web application that

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.