I needed to find a mechanism to limit a search that never exceeded 3 months.
I have two dates, I want to validate if they are within the defined parameters.
I have this code () I'm using type date and datepicker to run on multiple browsers
<script src="data/js/moment.js" type="text/javascript"></script>
<script type="text/javascript">
$("#pesquisa").on("submit", function (event) {
event.preventDefault();
var start= new Date(document.getElementById("datainicio").value);
var end = new Date(document.getElementById("datafim").value);
var dr = moment.range(start, end);
dr.diff('months'); // 3
dr.diff('days'); // 92
alert( dr.diff();) // 7945200000
// mostrarinfo();
});