I have table in my project
I have filtering by date in my table
Now it filters only by Date from value, but I want to filter it from-to dates.
How I can do this in my case?
Here is snippet that demonstrates my problem
$('#datefilterfrom').change(function () {
var date = moment(this.value).format('DD/MM/YYYY');
var filter, table, tr, td, i;
filter = date.toUpperCase();
table = document.getElementById("testTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[2];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<div class="row">
<div class="col-md-3">
<h4>Date from</h4>
<input type="date" class="form-control" id="datefilterfrom" data-date-split-input="true">
</div>
<div class="col-md-3">
<h4>Date to</h4>
<input type="date" class="form-control" id="datefilterto" data-date-split-input="true">
</div>
</div>
<table id="testTable" class="table" border="1">
<tr>
<td>nothing</td>
<td>nothing</td>
<td>18/07/2018</td>
<td>nothing</td>
</tr>
<tr>
<td>nothing</td>
<td>nothing</td>
<td>19/07/2018</td>
<td>nothing</td>
</tr>
<tr>
<td>nothing</td>
<td>nothing</td>
<td>20/07/2018</td>
<td>nothing</td>
</tr>
</table>
Thank's for help.