JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" class="numonly" />
JavaScript
$('.numonly').bind('keypress', function(event){
if (event.which > 31 && (event.which < 48 || event.which > 57)) return false;
});
<input type="text" class="numonly" />
$('.numonly').bind('keypress', function(event){
if (event.which > 31 && (event.which < 48 || event.which > 57)) return false;
});