[jQuery] Add commas while typing?

[jQuery] Add commas while typing?

Sunsean,
This IS really awesome!
I tried playing with it a little bit, is it possible to get the commas NOT to appear UNTIL the 4th, 7th, 11th character is typed? That way if they stop at 200 a comma is not there but if 2000 is entered ... wait it would be 200,0 at that point and not 2,000 ... hrmmm this might be too complex for what it is worth. But I play with it and it sure is a sweet idea.
Dan
-----Original Message-----
From: sunsean [mailto:littlecooldude@gmail.com]
Sent: Friday, June 09, 2006 6:00 PM
To: Acuff, Daniel (Comm Lines, PAC)
Subject: RE: Add commas while typing?
Hi there Daniel, jQuery can do exactly what you asked. Below I've
pasted a simple example of what you asked for.
<html><head><script type="text/javascript"
src="http://jquery.com/src/latest/"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#3key').keyup(function(){
if(this.value.length%4==3) this.value = this.value+",";
});
});
</script></head><body>
<input id="3key" type="text" />
</body></html>
Hope that helps, let me know if you have any questions.
~Sean
*************************************************************************
This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information. If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited. If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/