Home > other >  select2 library I want when entering the search input to convert to uppercase letter
select2 library I want when entering the search input to convert to uppercase letter

Time:02-08

If you can help me, I want that when writing in the select2 search box it automatically changes to uppercase I have no code to teach because I have searched and found nothing about it I attach an image

I put the inputs in automatic capital letters with onkeyup and I call the following function and I would like to do it in the select2

 function mayus(e) {
  e.value = e.value.toUpperCase();
 }

example

CodePudding user response:

You can't use onkeyup property on the select2 search input. You should instead use "event delegation". Try this

$(document).on('keyup', '.select2-search__field', function(e){
    e.target.value = e.target.value.toUpperCase()
});
  •  Tags:  
  • Related