I have the following line of JS written into my html on an input tag. I'm in class learning about separation of concerns and that we shouldn't put JS into our html. I've been trying to figure out a way to convert this lines:
onkeypress="return (event.charCode >= 65 && event.charCode <= 90) || (event.charCode >= 97 && event.charCode <= 122) || event.charCode == 32;"
To something like this:
document.querySelector("#login-first-name").addEventListener("keypress",function(event){
return (event.charCode >= 65 && event.charCode <= 90) || (event.charCode >= 97 && event.charCode <= 122) || event.charCode == 32;
});
Any insight would be great.