input box which automatically inserts dashes (-'s)

B

blackoap

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. :))
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Wed, 27 Sep 2006 10:03:50 remote, seen in
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top