In my coding work, I have crafted a function that detects the key pressed by the user through an event.
NameValidation(e){
if(!e.key.match(/^[a-zA-Z]*$/))
{
e.key = '';
console.log(e.key);
}
},
This function essentially verifies whether a special character or number has been entered by the user and if so, it replaces the special character/number with an empty string.
The problem arises when it comes to e.key = '';
.
Despite this line of code being present, the captured key is not actually replaced. What am I overlooking here?