Live table searching (jquery)

Hello,

I have a small code to filter data depending on what users types in the input box and also a database with different kind of mobile phones.

The plugin works fine aside from one little thing, for example …i have “Samsung Galaxy S4 I9505”.

If the user type only " S4 " or “Samsung” the plugin works, but if the user type only “Samsung S4” the plugin not working anymore,because is missing the “galaxy” word, the user need to type the name of the mobile phone in the same order as is stored in the database, if is missing on word, the plugin not work anymore.

How to modify this plugin to search for words in any order …for example “Samsung S4” or “Samsung I9505”?

Here is my code:

$(document).ready(function(){
	$("#searchInput").keyup(function(){
		
		if( $(this).val() != "")
		{
			
			$("#tablesorter-demo tbody>tr").hide();
			$("#tablesorter-demo td:contains-ci('" + $(this).val() + "')").parent("tr").show();
		}
		else
		{
			
			$("#tablesorter-demo tbody>tr").show();
		}
	});
});


$.extend($.expr[":"],
{
    "contains-ci": function(elem, i, match, array)
	{
		return (elem.textContent || elem.innerText || $(elem).text() || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
		return (elem.textContent || elem.innerText || $(elem).text() || "").toUpperCase().indexOf((match[3] || "").toUpperCase()) >= 0;
	}
});

Thank you

Hi Norbert,

The first thing that occurs to me is to split the search expression at the space and try and match the pieces against a regex.

e.g.

var words = "Samsung Galaxy".split(" ");
if (string.match(words[0]) && string.match(words[1])){
  // Whatever
}

Which plugin are you using?