You just need to create two Date objects by fields' values, then you can easily find difference in milliseconds and then convert it to minutes, hours or days simply by division:
var diff = new Date(field1.value).getTime() - new Date(field2.value).getTime();
// or the same
var diff = Date.parse(field1.value) - Date.parse(field2.value);
var days = diff / 1000 / 60 / 60 / 24;
However if you want to find out difference in months (month is not determined period of time) you need to decide what you mean by month.
For some applications you prefer to think of month as of 30.44 days (financial, statistics etc) or even about 21.7 working days.
In other cases, when you want to count the number of real months, your task is even simpler - get years and months from both dates and subtract them:
var d1 = new Date(field1.value);
var d2 = new Date(field2.value);
// d1.setTime(d1.getTime() + 15.22 * 24 * 60 * 60 * 1000);
var diff = d1.getYear() * 12 + d1 .getMonth() - d2.getYear() * 12 - d2.getMonth();
The line which is commented allows you to add compensation (about 15 days) to larger date so that error of result is -0.5...+0.5 instead of -1..0.