Javascript Code Error [duplicate]

1

Well, I have the following code in javascript:

< script type = "text/javascript" >
  function teste() {
    var date1 = document.getElementById("data");
    var date2 = document.getElementById("data2");
    var timeDiff = Math.abs(date2.getTime() - date1.getTime());
    var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
    alert(diffDays);
  } < /script>

In html I have the following code:

Book from: <input type="date" name="data" id="data" />

Up to: <input type="date" name="data2" id="data" onblur="teste()" />

I'd like to know why I'm following the date on inputs does not show a alert telling the number of days.

    
asked by anonymous 19.09.2015 / 14:08