So I need to specify that a number field be ONLY 11 characters long (it is an account number)
And I need to format my Calculations for Amount and Total, to only have / hold 2 decimal places - setting them as currency isn't doing it.
Here is my code for the calculations that I got from a Help File....
$(document).ready(function () {
$('.cf-table-block').on('blur', 'input', sumtotal);
if ($('.subtotal').length > 0) {
$('.cf-table-block').on('blur', 'input', rowtotal);
}
function sumtotal() {
var sum = 0;
$('td.sum').each(function () {
var s = 0;
$(this).find('input').each(function () {
s += parseNumber($(this).val());
})
$(this).find('.subtotal input').val(s);
sum += s;
});
$('.total input').val(sum);
}
function rowtotal() {
var sum = 0;
$('.cf-table-block tbody tr').each(function () {
var s = 0;
$(this).find('.sum input').each(function () {
s += parseNumber($(this).val());
})
$(this).find('.subtotal input').val(s);
sum += s;
});
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN(f) ? 0 : f; //treat invalid input as 0;
}
});