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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:19:16+00:00 2026-06-14T23:19:16+00:00

A client is asking that a textfield containing phone-number data be split into two

  • 0

A client is asking that a textfield containing phone-number data be split into two — one for country code, the other for the rest of the number.

Alas, this field is pretty hard-coded into the system and all data collected thus far has been as one consolidated field (and thus saved as one column in the database).

I’m thus thinking the best answer might be to do the following:

  1. Using Javascript, replace the single text field with two text fields.
  2. These then become merged back into the original text field when the user clicks the submit button.
  3. Bonus marks if there’s a way to separate that field back into two again when it’s read from the database (I.e., when an administrator views the entry). Note that the data format must be consistent — I don’t want to mix the existing string data with, say, a bunch of JSON strings.

Is this the best way to go about this? Are there any foreseeable problems (beyond the user not having JavaScript enabled) with this approach? Is there a jQuery plugin that’s designed to do stuff like this?

I also need to validate it as a valid phone number at some point, but I can figure that out myself.

  • 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-14T23:19:17+00:00Added an answer on June 14, 2026 at 11:19 pm

    If you dont want to use a plugin you can always check out this snippet I made on jsFiddle

    If you want to make sure it works in the JS just change the display:’none’ to display:’block’

    here is my JavaScript

    $(function() {
        $('#phone').css({ display:'none' });
        $('#phone').after(') <input type="text" name="phoneMainNumber" id="phoneMainNumber" />').after('(<input type="text" value="555" name="phoneAreaCode" id="phoneAreaCode" style="width:30px;" />');
        bindChange();
    });
    
    function bindChange() {
        $('#phone').val('('+$('#phoneAreaCode').val()+') ');
        $('#phoneMainNumber, #phoneAreaCode').keyup(function() {
           $('#phone').val('('+$('#phoneAreaCode').val()+') '+$('#phoneMainNumber').val());    
        });   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In one of our systems that uses Reporting Services 2005, the client is asking
So a client right now is asking me to send requests that are synchronous
My client is asking me to distribute a demo app that should only be
I'm writing a Java desktop client application that retrieves data from a remote MySQL
I want to be sure that the client asking for HTTP get requests at
A client is asking that I write a script to periodically pull his contacts
I have a client that is asking me to give them a listing of
I am asking about that as I am going to develop a client side
I'm asking on opinion about implementing framework that emulates ado.net in java (data tables,
I have a client that is asking for radio buttons with choices of green,

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.