JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="txt1"/> <!-- allow only nymeric -->
<input type="text" id="txt2"  /> <!-- allow only alphabets -->
<input type="text" id="txt3" /> <!- allow alphanumeric -->

JavaScript

jQuery.fn.NumericOnly =
function()
{
    return this.each(function()
    {
        $(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;            
            return (
                key == 8 || 
                key == 9 ||
                key == 46 ||
                (key >= 37 && key <= 40) ||
                (key >= 48 && key <= 57) ||
                (key >= 96 && key <= 105));
        });
    });
};

$("#txt1").NumericOnly();