Use Regex to replace the whitespace
filter = filter.replace(/\s/g, '')
EDIT for comment
filter = filter.replace(/\s/g,'')
txtValue = txtValue.replace(/\s/g, '')
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
CLICK HERE to find out more related problems solutions.