Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   input box which automatically inserts dashes (-'s) (http://www.velocityreviews.com/forums/t927245-input-box-which-automatically-inserts-dashes-s.html)

blackoap@gmail.com 09-27-2006 05:03 PM

input box which automatically inserts dashes (-'s)
 
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. :))


Dr John Stockton 09-27-2006 06:00 PM

Re: input box which automatically inserts dashes (-'s)
 
JRS: In article <1159376630.174141.86090@b28g2000cwb.googlegroups. com>,
dated Wed, 27 Sep 2006 10:03:50 remote, seen in
news:comp.lang.javascript, blackoap@gmail.com 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.


All times are GMT. The time now is 10:43 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.