Formatting currency fields using javascript

This actually uses jquery, but yo could replace the jquery with doc.getelem….

Here is a sick way to get rid of $ signs, commas and anything after decimal point.

for example: $45,000.45 becomes a clean number 45000 ready for calculations.

No, it doesnt round. just removes the change.

// strip out any $$ .00 and anything else
function stripper(who){
dirtynumber = $( who ).val();
cleannumber = parseInt(dirtynumber.replace(/[^d.]/g, “”));
$( who ).val(cleannumber);
}

Leave a Reply