V
V
vitya192020-05-13 20:23:41
JavaScript
vitya19, 2020-05-13 20:23:41

Why does replace javascript work crookedly?

Somehow replace works strangely, I need to prohibit the input of certain characters, and if it works at the beginning of the line, then it stops
Code: https://jsfiddle.net/sL5mqudn/1/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2020-05-13
@vitya19

You are only replacing the first character. You could add the /g modifier and remove the characters from the beginning and end of the line
/[а-я, 0-9]/g
But in general, it is better to do such things through preventDefault()

R
Rsa97, 2020-05-13
@Rsa97

You have written in: replace a string consisting of strictly one set character (capital Cyrillic letters, numbers, comma or space) with an empty string.
What is wrong with your program?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question