javascript converting and exploding string to number

You need to remove the dollar signs and commas, (string replace), then convert to a float value

Try this:

parseFloat('$148,326.00'.replace(/\$|,/g, ''))

See: http://www.w3schools.com/jsref/jsref_parseFloat.asp

Or: http://www.bradino.com/javascript/string-replace/

To handle other currency symbols you could use the following instead (which will remove all non numeric values (excluding a . and -)):

parseFloat('$148,326.00'.replace(/[^0-9.-]+/g, ''))

var s = '$148,326.01';
parseFloat(s.replace(/[^\d.]/g, '')); // => 148326.01

Tags:

Javascript