2

I want replace "İ" character to "i". This code works perfect without other jquery library in page. But it doesn't work with autocomplete script.

$k(document).ready(function(){   
    $k(".replace").on("keyup", function(){
        str = $k(this).val();
        var dizi = { "İ": "i" };
        str = str.replace(/(([İı]))+/g, function(harf){ return dizi[harf];     })
        $k(this).val(str);
    });   
});

Is there a way to solve it or any other code can use.

Thanks...

zokanzi
  • 117
  • 3
  • 15

1 Answers1

1

You can also trigger your function with

$(document).ready(function(){
  $('.replace').focusout(function(){
      str = $(this).val();
      var dizi = { "İ": "i" };
      str = str.replace(/(([İı]))+/g, function(harf){ return dizi[harf];});
      $(this).val(str);
   }).keyup(function() {
      str = $(this).val();
      var dizi = { "İ": "i" };
      str = str.replace(/(([İı]))+/g, function(harf){ return dizi[harf];});
      $(this).val(str);
   });
 });

UPDATE:

$(document).ready(function(){
    $(document).delegate('.ac_even', 'click', function(){
        str = $('.replace').val();
        str = str.replace('İ', 'i'); 
        $('.replace').val(str);
    });
    $('.replace').focusout(function(){
      str = $(this).val();
      str = str.replace('İ', 'i');
      $(this).val(str);
   }).keyup(function() {
      str = $(this).val();
      str = str.replace("İ", "i");
      $(this).val(str);
   });
});

See: How do you trigger autocomplete "select" event manually in jQueryUI?

so this will work if you focus out and if you hit something on the keyboard the Input/textarea and will do something.

  • Thanks a lot but I don't understand what i will do. – zokanzi Nov 28 '15 at 10:56
  • Your replace function will trigger if you hit some character or when you leave the input/textarea. –  Nov 28 '15 at 10:58
  • If i can, i will. I don't know where and what to write – zokanzi Nov 28 '15 at 11:30
  • Edited, are you turk? If yes I can talk to you how you do it in turkish. Tell me if this helped you. –  Nov 28 '15 at 22:50
  • Valla doğru diyorsun. Ama verdiğin kod çalışmadı. Autocomplete ile çakışıyor sanırım. Birini kaldırınca diğeri çalışıyor çünkü. – zokanzi Nov 29 '15 at 23:14
  • edem, sen bana o html kismini bana yolla. Ben yaparim o benden. –  Nov 29 '15 at 23:24
  • http://jsfiddle.net/zokanzi/ga4rvr7h/ kodları buraya attım ama, asp sayfası olduğundan deneme nasıl yapacaksın. http://kirsehirilan.net/deneme.asp buradan da sorunu görebilirsin. Cari kısmına SELİM yazdığımda kayıt gelmiyor. IE'de sorun yok da chrome'da gelmiyor kayıtlar. O yüzden İ'yi küçültmem gerekiyor. Teşekkürler şimdiden. – zokanzi Nov 30 '15 at 02:02
  • abicim yukarida yaptigim gibi dogru .focusout yapinca zaaten cevirmesi gerek. Sen herhalte codu yanlis ekledin. Simdi benim yazdigimi ekle. –  Nov 30 '15 at 15:51
  • Abi yok ya. kirsehirilan.net/deneme.asp adresine de ekledim. jquery sürümünden mi acaba anlamadım. Teşekkürler yine de, elinden geleni yaptın. – zokanzi Nov 30 '15 at 19:49
  • https://jsfiddle.net/zokanzi/pmgo0qrt/ buraya attım da burada da çalışmadı. class olarak değil başka bir şey olarak mı vermem gerekiyor. – zokanzi Dec 01 '15 at 01:28
  • sitende jQuery okunmuyor –  Dec 01 '15 at 08:27
  • Ekledim ya. Nedeni ne ki. Bir de autocomplete nasıl çalışıyor jQuery okunmuyorsa. – zokanzi Dec 01 '15 at 13:37
  • jquery baska bir link kullandin –  Dec 01 '15 at 17:07
  • jsfiddle.net/zokanzi/pmgo0qrt buradaki script niye çalışmıyor. – zokanzi Dec 01 '15 at 20:51
  • jsfiddle.net/zr36wnz9 buyur kocum hata bende, ben degistirdigimi geri inputa vermedigim icin böyle oldu kusura bakma kanka –  Dec 01 '15 at 21:07
  • Ya fiddle'daki çalışıyor da, benim sayfada çakışıyor birşeyle. Bulamadım valla. – zokanzi Dec 03 '15 at 17:14
  • Sayfanin linkini bi paylasabilirmisin? –  Dec 03 '15 at 17:17