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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:20:16+00:00 2026-05-21T15:20:16+00:00

I know the title doesn’t capture what I’m trying to ask but here is

  • 0

I know the title doesn’t capture what I’m trying to ask but here is what I’m trying to do:

// desired format is: 123-123-1234

When the user enters 123 (the first three characters) how can I append the hyphen –
Then when the user enters 123 (the second three characters) how can I append the hyphen – again
And then allow the user only to enter the last four numbers?

I have a function that validates the US Phone number format I want:

/* US Phone # */
'us_phonenumber':function($fld) {
    var v = $fld.val();

    if(v.length == 0) {
        return true;
    }
    return /^\d{3}-\d{3}-\d{4}$/.test(v);
},

Just curious if I could add some sort of partial auto complete method while still validating

  • 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-21T15:20:17+00:00Added an answer on May 21, 2026 at 3:20 pm

    HTML:

    <input type="text" />
    <br /><a href="#" id="check">Click me!</a>
    

    JS:

    $("#check").click(function(){
        var pNum = $("input").val();
        var vNum = pNum.slice(0, 3)+"-"+pNum.slice(3, 6)+"-"+pNum.slice(6, 10);
        $("input").val(vNum);
        return false;
    });
    

    Fiddle: http://jsfiddle.net/ueyhE/

    Type in your number, then press “Click me!”.

    EDIT:

    Using change():

    $("input").click(function(){
        var pNum = $(this).val();
        var vNum = pNum.slice(0, 3)+"-"+pNum.slice(3, 6)+"-"+pNum.slice(6, 10);
        $(this).val(vNum);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know the title of this question is a bit confusing, but here it
I know that title sounds crazy but here is my situation. After a certain
i want change title's color of navigation controller but i dont know why doesn't
Excuse my title if it's confusing, but I don't know how else to describe
Ok I know the title doesn't fully explain this question. So I'm writing a
I know the title sounds familiar as there are many similar questions, but I'm
I guess the title doesn't really say a lot, so here's the explanation. I
First off, I know my title can be formulated better, but my math classes
Not a very good title, but I didn't know what to name it. Anyway,
That title probably doesn't sound right, but forgive me, I'm learning Rails for the

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.