document.getElementById('search-input').addEventListener('keyup', (e) => {
    var text = e.currentTarget.value.toLowerCase();
    tableSearch(text);
});

document.getElementById('search-input').addEventListener('search', (e) => {
    var text = e.currentTarget.value.toLowerCase();
    tableSearch(text);
});

function tableSearch(text) {
    var filter, tr, td, i, txtValue;
    filter = text;
    tr = document.getElementById('contacts-table').getElementsByTagName("tr");
    for (i = 0; i < tr.length; i++) {
        td = tr[i].getElementsByTagName("td")[1];
        if (td) {
            txtValue = td.textContent || td.innerText;
            if (txtValue.toLowerCase().indexOf(filter) > -1) {
                tr[i].style.display = "";
            } else {
                tr[i].style.display = "none";
            }
        }
    }
}