Javascript toFixed() is not a function

Viewed 27139

I'm trying to format the user input values using following technique, but I get the following error on Fire Bug console

$(this).val().toFixed is not a function

$(".amount-text").bind('change',function () { 
     $(this).val(($(this).val()).toFixed(2));
}); 

Can some one help me on this?

4 Answers

HTML5 added the property valueAsNumber to the input element, so you don't need to apply parseFloat by yourself. (Documentation at MDN)

Related