VueJs Remove Spaces From Input Value


VueJs Remove Spaces From Input Value

Delete all spaces from input value:

<input type="text" name="card_number" v-model="foo">
<input type="hidden" name="bar" :value="foo.replace(/\s/g, '')">

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>