JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="textbox" />
JavaScript
$('#textbox').on('change keyup', function() {
var sanitized = $(this).val().replace(/[^0-9]/g, '');
$(this).val(sanitized);
});
<input type="text" id="textbox" />
$('#textbox').on('change keyup', function() {
var sanitized = $(this).val().replace(/[^0-9]/g, '');
$(this).val(sanitized);
});