#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    724
    Rep Power
    7

    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
    27
    How about this
  4. #3
  5. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,131
    Rep Power
    4304
    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
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    724
    Rep Power
    7
    Masked input... Thank you very much. Gotta love how such simple words unlock so much. ;-)
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    724
    Rep Power
    7
    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 and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him

IMN logo majestic logo threadwatch logo seochat tools logo