Categories:

Home / Free JavaScripts / Forms / Here

Cut & Paste Parse number to currency format

Credit: JavaScript Kit

Description: This is a handy script for forms that contain money values. It automatically parses the form element of your choice whenever a surfer enters a number into the standard currency format; In other words, a number in two-decimal format, with an optional dollar sign in front. The script can be configured to attach -or not attach- the dollar sign to the parsed number (so you can use the script simply to parse numbers to the two-decimal format, for example).

Example:

Enter a number:

Directions: Simply insert the below into the <head> section of your page:

The script is designed to allow multiple elements to all be parsed. Simply insert the below code into the element's tag:

onBlur="parseelement(this)"

For example:

<form>
<input type="text" size=10 onBlur="parseelement(this)">
<input type="text" size=10 onBlur="parseelement(this)">
</form>


JavaScript Tools:
Site Info

CopyRight 1998-2014 JavaScript Kit. NO PART may be reproduced without author's permission.