I
I
Ilyuxa Ko2018-07-06 11:41:14
JavaScript
Ilyuxa Ko, 2018-07-06 11:41:14

How to fix double characters when typing in a text box?

Good afternoon. I am new to vue and js.
I'm trying to implement on vue in conjunction with element-ui the replacement of Russian characters with Latin characters in accordance with the keyboard layout. Roughly speaking, I want to enter only the Latin alphabet with numbers in the field.
It turned out so far this jsfiddle.net/9sd1xbuv/13
The replacement occurs, but for some reason the character that you entered is added.
Although if you add the .prevent modifier to @keypress.native it seems to work, but then the validation will not work.
Either I was smart, or maybe something is wrong in the component?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
0
0xD34F, 2018-07-06
@iiiil

Instead of keypress, the input event should be handled. You don’t need to enter the value (in the sense - through element.value) into the element with your hands, let v-model do it. The very logic of replacing characters is wildly overcomplicated, I don’t see the point. Here 's the corrected version for you.

L
Lynchee, 2014-11-04
@Linchee

Nevermind!
Got it, bitches

D
dmestroone, 2014-11-05
@Dmestro

Nightmare.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question