0

I have found this link have a simple and useable funciton to convert number to currency.

www.mredkj.com/javascript/nfbasic.html

but how to turn it back form currency to number...

I already try this :

[http://jsfiddle.net/vb2cb1tm/3/]...

But its failed...

I try to read a formatted string using javascript and make a counting on this valua...

cweiske
  • 30,033
  • 14
  • 133
  • 194

2 Answers2

0
function cur2num(cur) {
  return parseFloat(cur.replace(/,/g,"");
}

if currency signs try /[^0-9]\.\-]/g as first argument to the replace

mplungjan
  • 169,008
  • 28
  • 173
  • 236
0

I think something as simple as

function numbers(nStr){
    return Number(nStr.replace(/[\$\,]/g,''));
}

might do the trick, though it's hard to tell without seeing your original code.

bobbylox
  • 13
  • 4