JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" placeholder="type:text">
<br>
<br>
<input type="number" placeholder="type:number"><br><br>
<input type="tel" placeholder="type:tel">

JavaScript

$('input').keypress(function (e) {
    if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
        return false;
    }
});