-1
I created a input
search and a list (side menu) below, when I do the search is ok, but I’m in trouble when any <li>
has voice with accentuation.
How could I implement a regular expression to help me?
$(function() {
$("#buscar-menu").keyup(
function() {
var menuBuscado = $(this).val().toUpperCase();
$(".menu-busca li").css("display", "block");
$(".menu-busca li").each(function() {
if ($(this).text().toUpperCase().indexOf(
menuBuscado.toUpperCase()) < 0) {
$(this).css("display", "none");
}
});
});
});
I wasn’t going to deny it, but forgive me, I had, because I find it very incorrect the attitude of some users to take something ready and paste in the reply and not at least credit the authors or the original post that helped you in part of the code. I ask you to always do this, because people deserve some recognition, as if you formulate a code and someone else should also use it, it is not a rule, but it is a matter of cordiality. I promise to even give you credit if you do and please don’t take it personally, it’s just constructive criticism.
– Guilherme Nascimento
Another suggestion, this code is not good, I recommend trying others more complete, which include
ç
or by usingNFD
(see about NFD and others on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)– Guilherme Nascimento
@Guilhermenascimento may have been careless and ignorant of the "creator" of this function on my part, but I have no idea who the author is, I’ve been using this function in my code for years to correct this same problem from the question above, for the next questions before using a function I did not create I will search if I find the author, often it may be even difficult by the amount of duplicated function that should exist, but thanks for the advice of quoting the author, I will pay more attention to that, constructive criticism is always welcome!
– Pedro Henrique
In codecs nothing is perfect to control, unless everything is very well done on the part of the author of the question, of course, but anyway a suggestion that can solve better, higher, minusculos, utf vs iso-8859-1/latin and others would be the use of this https://stackoverflow.com/a/37511463/1518921, if you edit the answer I can remove the downvote, because after 40 min it is no longer possible to remove unless q vc edit, it is a system lock. I stand by
– Guilherme Nascimento
Done, added as reference to code
– Pedro Henrique