JSFiddle - React, Tailwind, and code Playground
HTML
<form name = "RegForm" class="login">
<input type="text" name="username" id="username" placeholder="Enter your username">
</form>
JavaScript
userID_textfield.onkeydown = function(e) {
var prohibited = "!@#$%^&*()+=;:`~\|'?/.><, \"";
var prohibitedchars = prohibited.split("");
var prohibitedcharcodes = new Array();
for (var i = 0; i < prohibitedchars.length + 1; i++) {
prohibitedcharcodes.push(prohibitedchars[i].charCodeAt(i));
for (var a = 0; a < prohibitedcharcodes.length + 1; a++) {
if (prohibitedcharcodes[a] === e.which) {
return false;
}
else {
return true;
}
}
}
}