javascript - parse float with two decimals, -


this input

<input type="text" name="price" class="solo-numeros"> 

with function

$(".solo-numeros").blur(function() {     var numb = parsefloat($(this).val().replace(/\d/g,"")).tofixed(2);     $(this).val(numb); }); 

i try change result input float 2 decimals

so try

555.61 

but on blur value change to

55561.00 

why that????

this happens because you're removing non-numeric characters (\d), such period. "55.61" becomes "5561", made two-decimal string-representation of float, hence "5561.00"

references:


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -