I am trying to make an input text that only write \[A-Za-z0-9 -]\
so i put the condition in onkeydown function. It works well. Almost. If you write ẃéŕýúíó
(something with accent mark) it doesn't work.
Extreme case:
<input type="text" onkeydown="return false;"/>
I can write á
. How to prevent it?
Edit:
Code with \[A-Za-z0-9 -]\
const verif = (event) => {
const char = event.key
if(char!=="Unidentified"){// when á return Unidentified
return /[A-Za-z0-9 -]/.test(char)
}else{
console.log("why!!")
return false
}
}
//tested on chrome 72
<input type="text" onkeydown="return verif(event);" />