A
A
Alex Polyakh2017-09-06 11:05:00
Python
Alex Polyakh, 2017-09-06 11:05:00

ReactJS, onChange event on input, how to detect 'Backspace' button is currently pressed and return to previous input?

There are 4 inputs with a maximum length of 2.
When we enter values ​​into inputs, then remove, and the condition (e.target,value < 1), jump to the forward input with el.previousElementSibling.focus()
Condition:
const regExpValidationInputOnlyNumber = /^[0-9\b]+$/;
if (!event.target.value.length && event.target.value === regExpValidationInputBackspace.test(event.target.value)) {
event.target.previousElementSibling.focus();
console log('true');
}
Please tell me what I'm writing wrong. Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
alfss, 2019-05-17
@alfss

https://kivy.org/doc/stable/api-kivy.uix.button.html

V
Vladimir, 2019-05-17
@vintello

in response to the header - no,
because first, before using kiwi, you need to understand how python itself works. it's like driving a car and not having a license

K
kulaeff, 2017-09-06
@kulaeff

The code you provided will focus the previous input if the current input is empty and validated (wtf?). You need to attach two handlers to inputs: input and keydown. In the keydown handler, you look at which key was pressed and, if backspace was pressed, set a boolean to tell you to jump to the previous input if the current input becomes empty.
Example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question