JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" name="test" />

JavaScript

$('input').on('input', function (e) {
    this.value = this.value.replace(/\D/g,''); 
});