#1
  1. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,365
    Rep Power
    24

    Format input on-the-fly (Phone Number)


    Howdy. I so must be typing in the wrong search elements when I hop Google. I see INPUT fields do this around the net. A few snippets I do find are always after the 10-digit is typed in. I try to interpret them to run on-the-fly, but error because of the ()- characters entered and being less than 10 digits.

    As far as triggers, like:
    Code:
    $().on('change keydown paste input', function() {})
    I am fine with. It's the taking whats in the box and updating it each character or paste/blur. Any ideas? Thank you for any input!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    29
    How about this
  4. #3
  5. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,104
    Rep Power
    4306
    To add to mod_speling's reply, yeah, that's a hard thing to find if you don't know that it's called "masking". I did find this result (without using the term in my search query) which mentions the term.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,365
    Rep Power
    24
    Masked input... Thank you very much. Gotta love how such simple words unlock so much. ;-)
  8. #5
  9. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,365
    Rep Power
    24
    Hmmm...I can maybe make it work. Is it possible w/ a phone number to make area code optional? This isn't the way I was really aiming for, but may work. I was aiming for the same way a cell phone edits the visual number as you type it. Only adds hyphens after so many characters, and not the full build from the start.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.

IMN logo majestic logo threadwatch logo seochat tools logo