JSFiddle - React, Tailwind, and code Playground

by gaby de wilde

HTML

<input type="text" inputmode="numeric" value="garbage">
<br>inputmode="numeric" but you can type letters in it!
<br><br>
<input type="number" value="garbage">
<br> type="number" you can type letters in this too!
<br><br>
<input type="text" oninput="validate(this)" value="">
<br>this isn't very complicated? 
<br>inputmode="numeric" might be useful here.

JavaScript

validate=x=>x.value=x.value.replace(/\D/g,'');