I want to check two conditions for every button press on the keyboard inside a textarea
:
1) If it's a number then add it to the text area.
2) If it's anything else push an alert to the user.
The textarea
tag in the html is:
<textarea id="input" placeholder="EnterInput"></textarea>
What I wrote inside the JS file is:
document.getElementById("input").addEventListener("keypress", checkInput(e));
function checkInput(keyPressed){
if(keyPressed < 48 || keyPressed > 57){
alert("Wrong input! The charcted entered is not a number.");
}
}