I have two fields in my form where users select an input time (start_time, end_time) I would like to, on the change of these fields, recalcuate the value for another field.<
var start = '5:30'; var end = '7:50'; s = start.split(':'); e = end.split(':'); min = e[1]-s[1]; hour_carry = 0; if(min < 0){ min += 60; hour_carry += 1; } hour = e[0]-s[0]-hour_carry; min = ((min/60)*100).toString() diff = hour + ":" + min.substring(0,2); alert(diff);