JSFiddle - React, Tailwind, and code Playground

HTML

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

JavaScript

$("#number").bind('keyup change click', function() {
    if ( $.trim($(this).val()) != "") {
        if ($(this).val().match(/^\d+$/)) {
        } else {
         $(this).val( $(this).val().replace(/[^0-9]+/gi, "") );
        }
    }
});