JSFiddle - React, Tailwind, and code Playground
by user2314737
HTML
<input class="validate-foating-value" type="text" />
JavaScript
$(document).ready(function () {
$(".validate-foating-value").bind('input propertychange', function () {
if (!/^[0-9]*\.?[0-9]*$/.test($(this).val())) {
var currentVal = $(this).val();
$(this).val(currentVal.slice(0,-1));
}
});
});