VueJs Input Uppercase


VueJs Input Uppercase

VueJs Model method:
<input type="text" v-model="name" @input="name=name.toUpperCase()">

Pure JS method:
<input type="text" v-model="name" onkeyup="this.value=this.value.toUpperCase();">

VueJs Model method (with Turkish language function):
<input type="text" v-model="name" @input="name=name.turkishToUpper()">

<script>
/*TR UpperCase()*/
String.prototype.turkishToUpper = function(){
  var string = this;
  var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "ü": "Ü", "ö": "Ö", "ç": "Ç", "ı": "I" };
  string = string.replace(/(([iışğüçö]))/g, function(letter){ return letters[letter]; })
  return string.toUpperCase();
}
/*TR UpperCase*/
<script>

Yorumlar

  1. String.prototype.turkishToUpper = function(){
    var string = this;
    var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "ü": "Ü", "ö": "Ö", "ç": "Ç", "ı": "I" };
    string = string.replace(/(([iışğüçö]))/g, function(letter){ return letters[letter]; })
    return string.toUpperCase();
    }

    burayı vue formatına nasıl getirebiliriz.

    YanıtlaSil

Yorum Gönder