JSFiddle - React, Tailwind, and code Playground

by Rahul Saraswat

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<input type="tel" id="tbNumbers" value=""
            onkeypress="javascript:return isNumber(event)" />

JavaScript

function isNumber(evt) {
        var iKeyCode = (evt.which) ? evt.which : evt.keyCode
        if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57))
            return false;

        return true;
}