JSFiddle - React, Tailwind, and code Playground

HTML

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

JavaScript

$('#txt').keypress(function (e) {
        var code = e.which;
        var key = String.fromCharCode(code);
        
        var pattern = /[a-zA-Z]|\./g;
       
        var isMatch = pattern.test(key);
        if (isMatch) {
            // DO NOT RENDER CHARS & dot
            e.preventDefault();
            
        }
    });