mdbootstrap / bootstrap-templates

A collection of free Bootstrap 5 templates.
https://mdbootstrap.com/freebies/
3.07k stars 1.01k forks source link

There should be an option to ignore the case of tags. #644

Closed hemal2cool closed 2 years ago

hemal2cool commented 6 years ago

At present, it is possible to add the same tag if it has a different case i.e. it is possible to add the tags "Cairo" and "cAiro", which is the same.

Using tagsinput js, we are facing the above issue. There should be an option to ignore the case of tags, turning it "true" won't allow the tags having the same value but different case.

Regards, Hemal PAtel

pablocorezzola commented 5 years ago

You can temporarily try adding to your code. It is not native but it will work:

$('input').on("beforeItemAdd", function(e){ 
   var name = e.item; 
   var allow = true;
   $(this).prev().find(".tag").each(function(i, valor){
       if ($(this).text().toLowerCase() == name.toString().toLowerCase()){
           allow = false;
           return false;
       }
   })

   if (!allow){
       console.log("repeat");
       e.cancel = true;
   }
});