JSFiddle - React, Tailwind, and code Playground

by nevkatz

HTML

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

JavaScript

let input = document.getElementById('test');

input.addEventListener('input', function() {
  let n = this.value.replace(/[^0-9]/, '');
  console.log('n: ' + n);
  this.value = n;
});