JSFiddle - React, Tailwind, and code Playground

HTML

<label for="txtAlpha">Alpha numeric textbox: </label>
<input id="txtAlpha" type="text" />

CSS

body
{
    color: #999;
    font-family: Lucida sans Unicode;
    font-size: 12px;
}

JavaScript

$(function()
  {
      $('#txtAlpha').keypress(function(e)
      {
          var code = e.keyCode ? e.keyCode:e.which; // Get the key code.
          var pressedKey = String.fromCharCode(code); // Find the key pressed.
          if(pressedKey.match(/[a-zA-Z0-9]/g)) // Check if it's a alpanumeric char or not.
          {
              e.preventDefault(); // If it is not then prevent the event from happening.
          }
      });
  });