input box which automatically inserts dashes (-'s)

Discussion in 'Javascript' started by blackoap@gmail.com, Sep 27, 2006.

  1. Guest

    I envision a credit card text input box which only allows numbers and
    dashes -'s.... and after you type 4 numbers it inserts a dash, and so
    on until the sequence is complete. I have no idea how to write this
    JavaScript function except for the dream of how it works. You will
    greatly help me expand my capability and learning curve (and help me
    finish this dang project!) ... if you can help me with this. Thank you
    for any assistance. :))
     
    , Sep 27, 2006
    #1
    1. Advertising

  2. JRS: In article <>,
    dated Wed, 27 Sep 2006 10:03:50 remote, seen in
    news:comp.lang.javascript, posted :
    >I envision a credit card text input box which only allows numbers and
    >dashes -'s.... and after you type 4 numbers it inserts a dash, and so
    >on until the sequence is complete. I have no idea how to write this
    >JavaScript function except for the dream of how it works. You will
    >greatly help me expand my capability and learning curve (and help me
    >finish this dang project!) ... if you can help me with this. Thank you
    >for any assistance. :))


    That gets rather confusing for the unsuspecting typist.

    IMHO, it's better to allow anything to be typed, and after that to strip
    out all non-digits (with a RegExp) and redisplay the input with spaces
    at the intervals that they occur on cards.

    It's a good idea to read the newsgroup and its FAQ. See below.
    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Sep 27, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Bedford
    Replies:
    0
    Views:
    430
    Chris Bedford
    Aug 17, 2003
  2. enrique
    Replies:
    2
    Views:
    571
  3. ashutosh
    Replies:
    3
    Views:
    9,011
    Andrew Thompson
    Jun 16, 2005
  4. cjl
    Replies:
    1
    Views:
    10,506
    Michael Winter
    Oct 31, 2005
  5. cjl
    Replies:
    7
    Views:
    187
    Thomas 'PointedEars' Lahn
    Oct 30, 2005
Loading...

Share This Page