I have approximately 50 hidden divs I want to sort via keyword matching. To simplify the example, I am currently only showing two. The script works great for English, but when you localize certain words they can contain accents which breaks the ability for the script to find a matched result. Example: in Spanish typing telefono does not match teléfono. I see examples where accents are removed from one string, but how do you remove them from all strings?
<form action="" class="styled" id="live-search" method="post">
<fieldset>
<p style="padding-left: 10px; padding-top: 5px;">Start typing to filter.</p>
<input class="text-input" id="filter" style="margin-top: -60px;" type="text" value="" />
<div id="filter-count"></div>
</fieldset>
</form>
<div>
<p class="listheaders"><strong>Phones:</strong></p>
<ul class="vglist">
<li class="listitems"><a href="/en/node/38871" target="_blank">Téléphone Android Nexus 5x<br />
<img src="someImagePathEtc" width="100" /> </a> <span style="display: none;">teléfono phone nexus 5x</span></li>
<li class="listitems"><a href="/en/node/33302" target="_blank">Einlösen von Geschenkkarten<br />
<img src="someImagePathEtc" width="100" /></a> <span style="display: none;">gift cards</span></li>
</ul>
</div>
<script>
$(document).ready(function(){
$("#filter").keyup(function(){
// Retrieve the input field text and reset the count to zero
var filter = $(this).val(), count = 0;
// Loop through the visual guide list
$(".vglist li").each(function(){
// If the list item does not contain the text phrase fade it out
if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).fadeOut("slow");
// Show the list item if the phrase matches and increase the count by 1
} else {
$(this).show();
count++;
}
});
// Update the count
var numberItems = count;
$("#filter-count").html(" Number of Guides: "+count);
});
});
</script>
I need to update the following fiddle such that it will match characters typed with our without accents. Thank you