I need help troubleshooting the code I got from another answer on this site, and tried to use in my form. I need to calculate the difference between two fields in a table row. The value I'm getting in the total field is "NaN." Below is an image of the table, and the code I used. Thank you for your help!!!
CSS Class in the "This Travel Time" field is CalcInput Trip
CSS Class in the "Normal Travel Time" field is CalcInput Normal
CSS Class in the "Net Travel Time" field is Total
$(document).ready(function () { $('.CalcInput').on('blur', 'input', calctotal); function calctotal() { var s = parseNumber($('.Trip input').val())-parseNumber($('.Normal input').val()); $('.Total input').val(s); } function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } });