Do it this way:
Code: Select allfunction differenceInDays(startDate, endDate) {
var oEnd = moment(endDate);
var oStart = moment(startDate);
var result = '';
if (oStart.isValid() && oEnd.isValid()) {
result = moment.duration(oEnd.diff(oStart)).asDays();
}
$("#differenceInDays").setValue(result);
}
$("#projectStarts").setOnchange(function(newVal, oldVal) {
differenceInDays( newVal, $("#projectEnds").getValue() );
})
$("#projectEnds").setOnchange(function(newVal, oldVal) {
differenceInDays( $("#projectStarts").getValue(), newVal );
})
(4.69 KiB) Downloaded 227 times