muhammed / interactive-card

Credit card form with smooth and sweet micro-interactions

Home Page:https://codepen.io/JavaScriptJunkie/pen/YzzNGeR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uppercase Card Name

ayhankesicioglu opened this issue · comments

How can I change cardName input value to uppercase using vuejs or mask?

I try this
<input type="text" name="cc_owner" id="cardName" class="card-input__input" v-model="cardName" v-on:focus="focusInput" v-on:blur="blurInput" data-ref="cardName" autocomplete="off" onkeyup="this.value = this.value.toUpperCase();>
But last character of cardName isn't change.

you can try this. it will work;

@input="cardName = cardName.toUpperCase()"

Thanks @MuhammedErdem . It's working. And I add a function for Turkish.
<input type="text" id="cardName" class="card-input__input" v-model="cardName" @input="cardName = cardName.turkishToUpper()" v-on:focus="focusInput" v-on:blur="blurInput" data-ref="cardName" autocomplete="off">

...

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

Very nice!