JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" />
JavaScript
$('input').on('keyup', function () {
this.value = this.value.replace(/[^0-9]/gi, '');
});
<input type="text" />
$('input').on('keyup', function () {
this.value = this.value.replace(/[^0-9]/gi, '');
});