JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="test" name="test"/>
JavaScript
var input = document.getElementById("test");
input.oninput = function(e){
if (/\D/g.test(this.value))
{
// Filter non-digits from input value.
this.value = this.value.replace(/\D/g, '');
}
}