JSFiddle - React, Tailwind, and code Playground

HTML

<input class="numericInput">

JavaScript

$('input.numericInput').keypress(function (e) {
    return /[0-9]/.test(String.fromCharCode(e.which));
});