JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" name="" id="user" />

CSS

input {
    padding: 5px 8px;
    font-size: 15px;
    outline: none;
    color: #333;
}

JavaScript

$(function(){
    $("#user").keypress(function(event){
        if ((event.charCode >= 48 && event.charCode <= 57) ||
            (event.charCode >= 65 && event.charCode <= 90) ||
            (event.charCode >= 97 && event.charCode <= 122))
            alert("0-9, a-z or A-Z");
    });
});