S
S
Sergey2020-05-20 12:23:15
JavaScript
Sergey, 2020-05-20 12:23:15

What is the logic in the condition?

Here is a piece of code for the input.

input.addEventListener('keypress', (e)=>{
            if(e.key.match(/[^а-яё 0-9]/ig)){
                e.preventDefault()
            }

It forbids entering Latin letters, but I can not understand this logic. If there is a Russian character - the condition is true and the default action is canceled - that is, the character is not entered. If there is no symbol, respectively, false and the Latin alphabet is written in the input. But it works the other way around. Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-05-20
@Banjamin

it works the other way around

because ^

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question