Move comma position JavaScript -
i'm trying move position of comma use of javascript. have managed remove parts of string needed removing. problem comma in wrong position.
the current outcome 425.00
, want '42.50'
success: function(result) { if (result != '') { alert(" "+result+" "); } var discountval = result.replace(/\d/g,''); newdiscountval = discountval.replace(7.50, ''); $("input#amount").val(discountval); }
i grabbing database echo values combination of string , echo - numbers..
if number can divide 10
if string can this:
var ind = text.indexof('.'); text = text.replace('.', ''); text.slice(0, ind-1) + '.' + text.slice(ind-1, text.length)
Comments
Post a Comment