Navigation Menu

What's New?
Alphabetical Listing
Site Contents


Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Become a Partner

Internet.commerce

Be a Commerce Partner














Internet.com

IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Developer Channel

FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

Great Sites

DocJavaScript.com
dhtml.com
The Freebie Directory
TheFreeSite.com

Browse Doc JS's Tips!


Hiermenus Central


Promotions

Free Announcements


Social Bookmark

General

Inserts the proper seperators to automatically format any currency field.


Enter Value:

Notes

  • Created by: Mario Costa
  • Posted: May 11, 2001

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: autoCurrency.js


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


User Comments

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

13. From: gmac
Coverted to Jquery
07/30/2008 14:10:04

Hi, just wanted to say this code is excellent. I managed to convert it to JQuery so now instead of calling the function I just add a (class = "currency") to any input field and it works beautifully, Much thanks to the author.

11. From: yassen
add the $ signe
11/16/2007 06:02:32

How Can I add the doller signe "$" at the start

12. From: Lee (Admin)
11/21/2007 12:31:41

You could add it at the beginning, outside of the box, e.g.,
Enter Value: $

9. From: Beto
About the formatting
11/14/2007 14:55:41

If you place the pointer in the integer part of the number and erase a digit, the comma should adjust to the new cipher, moving to the right position. Right now that is not happening

10. From: Lee (Admin)
11/15/2007 16:11:52

Yes, you're right. That's a result of how it was written. Due to the limitations of these comments, you will need to contact the author or submit your question to the JavaScript Forum for further help.

4. From: Emile
Rad
10/22/2007 06:16:56

Or like this

if(window.event) // IE
{
whichCode = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
whichCode = e.which;
}

thanx.

3. From: Emile
great code snippet
10/22/2007 05:55:03

Hi,

This code rocks!

I just think this line is the wrong way around

"var whichCode = (window.Event) ? e.which : e.keyCode;"

should be:
var whichCode = (window.Event) ? e.keyCode : e.which;

... I think... : )

But again, thanx for the code.

7. From: charles
no tab control in Firefox
10/02/2007 18:28:47

In Firefox/2.0.0.7, Once the input field receives focus, you can no longer TAB to the next field, nor shift TAB to go backwards...
anyone have any thoughts as to why that might be?

14. From: Brian
07/17/2008 15:29:06

What you need to do to fix this is add the following two lines to the rest of the special characters (under codes 8 and 13):

if (whichCode == 9) return true; // Tab
if (whichCode == 11) return true; // Tab

8. From: Lee (Admin)
11/06/2007 12:00:50

You will need to submit your question to the JavaScript Forum for further help.

next comments...

Do you write JavaScripts?
If you do, why not submit them to us?
We'll give you credit and a link back to your Web site.