JSFiddle - React, Tailwind, and code Playground

by Shree Khanal

HTML

<input type="text" id="txtAlpha" />
<span id="spnmsg"></span>

CSS

#spnmsg { color: red; }

JavaScript

$(function () {
    $('#txtAlpha').keydown(function (e) {
        if (e.shiftKey || e.ctrlKey || e.altKey) {
            $("#spnmsg").html("Only Alphabet ").show().fadeOut("slow"); 
            e.preventDefault();
        } else {
            var key = e.keyCode;
            if (!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) {
                 $("#spnmsg").html("Only Alphabet ").show().fadeOut("slow");
                e.preventDefault();
            }
        }
    });
});