Answer the question
In order to leave comments, you need to log in
How to allow input of certain characters?
Tried onKeyUp with code like this:
event.target.value = event.target.value.replace(/[^-A-Za-zА-Яа-я]/gi, "");
Answer the question
In order to leave comments, you need to log in
onKey(event: KeyboardEvent) {
console.log(event);
//189 - тире
if (event.keyCode != 189 && !String.fromCharCode(event.keyCode).replace(/[^0-9A-Za-zА-Яа-я]/gi, "")) return false;
//(<HTMLInputElement>event.target).value = (<HTMLInputElement>event.target).value.replace(/[^-A-Za-zА-Яа-я]/gi, "");
}
But it works a little wrongWhen the code for checking certain characters is a little wrong , it needs to be fixed a little in a certain way .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question