Answer the question
In order to leave comments, you need to log in
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
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
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 questionAsk a Question
731 491 924 answers to any question