JSFiddle - React, Tailwind, and code Playground

HTML

<input id="myTextBox" type="text" />

JavaScript

$('#myTextBox').bind('input propertychange', function() {
    var filteredText = $(this).val().replace(/[^\d]/gi, '');
    $(this).val(filteredText);
});