achat viagra efficace vendo cialis roma viagra svizzera ricetta viagra marque compra generico levitra viagra indio vendita viagra in svizzera günstig viagra cialis ne marche pas viagra online prezzo pi c b basso pastillas baratas kamagra cialis bestellen forum acheter du viagra livraison rapide viagra envios rapidos levitra bayer 10 mg
prix du medicament levitra 
viagra 25 mg prix 
acheter viagra pharmacie sans ordonnance 
pharmacie en ligne paris 
cialis générique 
viagra pour les femmes 
acheter viagra generique belgique 
trouver du levitra 
achat levitra quebec 
prix du viagra 
cialis generique 10mg 
cialis generique indien 
levitra doctissimo 
ou commander du viagra sur internet 
buy viagra 
buy bupropion sr online without prescription viagra generic cialis buy tarif priligy levitra price priligy kamagra tablets where can i buy viagra kamagra without prescription viagra generic priligy dapoxetine buy cialis without prescription cheap kamagra online buy dapoxetine online kamagra mg

Introducing Tiny JavaScript Number Formatter

For a current project, I created a tiny number formatter that inserts thousand delimiters in a string:

10000 to 10,000 etc.

Just add css class=”numberformat currency” to a text field, and it will be formatted automatically.

It is based on the Prototype JavaScript library. You can get it from it’s GitHub repository page. Feel free to add or alter the functionality. Releasing under Creative Commons license.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

Some quick notes:

I’m using this on a rather big HTML page, so the selection of DOM nodes must be as simple and quick as possible. So if you are considering moderations, please make sure that the DOM manipulations are as lightweight as possible.

The script is as simple as possible. It does not parse the string as a number. Instead it just strips any thousand delimiters in the string. Afterwards it sets its own. There may be some important logic here to add to make the code more robust.

I have also added a test page to the project… not a real test page, but a HTML page that shows examples that are modified. Please back up any added functionality with changes to that page as well.

Contact me for commit access if you would like to contribute. I do not expect to add any functionality to the code unless the work project requires it.

More info:
GitHub repository

Technorati Tags: , , ,

One Response to “Introducing Tiny JavaScript Number Formatter”

  1. David Says:

    Interesting. I suppose it could easily be modified to add things like $ signs, decimals as well.