JSFiddle - React, Tailwind, and code Playground

HTML

<body>
    <script>
        function numbersOnly(oToCheckField, oKeyEvent) {
            return oKeyEvent.charCode === 0 || /\d/.test(String.fromCharCode(oKeyEvent.charCode));
        }
    </script>
    <form name="myForm">
        <p>Enter numbers only:
            <input type="text" name="myInput" onkeypress="return numbersOnly(this, event);" onpaste="return false;" />
        </p>
    </form>
</body>