JSFiddle - React, Tailwind, and code Playground
by zlojnaxa
HTML
<input type="text" id="inp">
JavaScript
var inp = document.getElementById('inp');
inp.onkeypress = (e) => !/[0-9\d]/i.test(e.key) ? false : true;
by zlojnaxa
<input type="text" id="inp">
var inp = document.getElementById('inp');
inp.onkeypress = (e) => !/[0-9\d]/i.test(e.key) ? false : true;