JSFiddle - React, Tailwind, and code Playground
HTML
<input id="input1" type="text" />
CSS
4
JavaScript
$('#input1').keyup(function(){
var val = $(this).val().match(/\d+([.]\d{1,2,3,4,5,6,7})?/);
val = val == null || val.length == 0 ? "" : val;
$(this).val(val);
});