function func() {
      date1 = new Date(date1.value);
      date2 = new Date(date2.value);
      var milli_secs = date1.getTime() - date2.getTime();
      
      // Convert the milli seconds to Days
      var days = milli_secs / (1000 * 3600 * 24);

      
      $a2=document.getElementById("ans").innerHTML =
      Math.round(Math.abs(days));
    
           if ($a2 > 1) {
  document.getElementById("ans").innerHTML = "Hours should be less than or equal to 24";
}
  else
  {
    document.getElementById("ans").innerHTML = "Date inserted";
}
    }   