Auto Currency | JavaScriptSource

Auto Currency

Mario Costa May 11, 2001

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


Leave a Response

(14 comments)

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.

gmac Jul 30, 2008

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):[br /][br /] if (whichCode == 9) return true; // Tab[br /] if (whichCode == 11) return true; // Tab

Brian Jul 17, 2008

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

Lee Nov 21, 2007

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

yassen Nov 16, 2007

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 [a href="http://www.webdeveloper.com/forum/forumdisplay.php?f=3"]JavaScript Forum[/a] for further help.

Lee Nov 15, 2007