I have the following code:
window.total = 0;
$('.amount').each(function(){
if($(this).val()){
window.total += parseFloat( $.trim($(this).val()).replace(',',''));
}
});
console.log(window.total);
for this example, there is only one input with the class .amount (there can be many), when the user enters a number with 7 digits and 2 decimal points, the above code cuts the number down to 4 digits.
Anything less then 7 digits it works fine. Any ideas why this is happening?
Js Fiddle : Demo