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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:55:05+00:00 2026-05-22T21:55:05+00:00

Does anyone know how to go about creating field that would perform telephone number

  • 0

Does anyone know how to go about creating field that would perform telephone number format masking, like here (___) ___-____:
http://www.smartclient.com/smartgwt/showcase/#form_masking

  • 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-22T21:55:06+00:00Added an answer on May 22, 2026 at 9:55 pm

    A better approach would be to let the user type whatever they want: “789-555-1234” or “(789) 555-1234” or “7895551234” and then when the field loses focus decide if what they typed can be a phone number. If so you can reformat it as “(789) 555-1234”. There are several related questions about how to do that sort of thing with regular expressions; just be sure your regex accepts the format you’re changing the user’s input to, otherwise it will be really annoying to edit.

    As an example, look what happens when you type “.5” into the left margin field in Microsoft’s standard page setup dialog: when you tab out it changes it to “0.5”.

    UPDATE: Here’s sample code in GWT to illustrate. For the sake of this example, assume there’s an element called “phoneContainer” to put the text box in. GWT doesn’t give you the full java.util.regex package, but it gives enough to do this:

    private void reformatPhone(TextBox phoneField) {
        String text = phoneField.getText();
        text = text.replaceAll("\\D+", "");
        if (text.length() == 10) {
            phoneField.setText("(" + text.substring(0, 3) + ") " + text.substring(3, 6) + "-" + text.substring(6, 10));
        }
    }
    
    
    public void onModuleLoad() {
        final TextBox phoneField = new TextBox();
    
        RootPanel.get("phoneContainer").add(phoneField);
        phoneField.addBlurHandler(new BlurHandler(){
            public void onBlur(BlurEvent event) {
                reformatPhone(phoneField);
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know about a SQL statements parser, in Java, that would allow having
Does anyone know about any API's, IDE's or such that simplifies the development of
Does anyone know how I would go about changing (transforming) an image based on
Does anyone know how I can go about hiding the tab selectors for the
Does anyone know any more details about google's web-crawler (aka GoogleBot)? I was curious
Does anyone know of any resources, examples or tutorials about testing ember.js apps ?
Does anyone know about this?
does anyone know about some good sources about counting complexity of recursive algorithms? somehow
Does anyone know if there are studies done that show the performance overhead of
Does anyone know how to go about displaying a custom homepage when Pubby is

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.