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
Post a Comment