Michael Stone
Michael Stone

Reputation: 950

Currency mask with jQuery

I'm using the jQuery calculation and have just about everything working properly, but I need the total to display as 99.90, not 99.9 (for example).

So .toFixed() isn't working for some reason when it should be! I can't find a mask that would work with this problem. Anyone have any other ideas?

Upvotes: 2

Views: 12799

Answers (2)

Al.
Al.

Reputation: 2882

Instead of this line:

$(".sumit").sum("keyup", "#totalSum");

Use:

$('.sumit').keyup(function(){
  var totalsum = $('.sumit').sum();
  $('#totalSum').val(Number(totalsum).toFixed(2));
});

Hope that helps

Upvotes: 1

Daniel Moura
Daniel Moura

Reputation: 7956

You can use toFixed

var num = 99.9;
num.toFixed(2);

Upvotes: 3

Related Questions