JSFiddle - React, Tailwind, and code Playground

by umer qureshi

HTML

<input type="text" class="decimal" value="" />

JavaScript

$('.decimal').keypress(function(evt){
    return (/^[0-9]*\.?[0-9]*$/).test($(this).val()+evt.key);
});