JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" value="" id="campo"/>

JavaScript

$('#campo').keypress(function(event) {
    if (((event.which != 46 || (event.which == 46 && $(this).val() == '')) ||
            $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
        event.preventDefault();
    }
}).on('paste', function(event) {
    event.preventDefault();
});