I use this code to calculate the sum : http://jsfiddle.net/QmTNZ/2/
I want to modify it, to show 0 when there is no valid quantity or it is empty and not “NaN”
I want also to format the Sum to have only 2 numbers after the comma.
Help (I’m beginner in jquery).
You can use the
isNaNfunction to check whether a number is actually a number or not:To round the sum to 2 decimal places, you could do something like this:
Here is an updated fiddle showing how it could work.