In a form I am creating I have the following table:
when I click the Date picker I get this:
here is the JS I am using:
$(document).ready(function () {
$.getScript('http://server/Forms/js/moment.js');
$('.cf-table-block').on('blur', 'input', sumtotal);
$(document).on('click', '.form-del-field', sumtotal);
function sumtotal() {
var hour = 0;
var rate = 0;
var total = 0;
var subtotal = 0;
$('.cf-table-block tbody tr').each(function () {
hour = moment($(this).find('.hour input').val(), 'HHmm');
rate = moment($(this).find('.rate input').val(), 'HHmm');
subtotal = hour.diff(rate, 'hours', true);
$(this).find('.total input').val(subtotal.toFixed(2));
total += subtotal;
});
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN (f) ? 0 :f; //treat invalid input as 0;
}
});
What am I doing wrong; How do I make the NaN not appear?