JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" class="test"/>

JavaScript

$(".test").keyup(function (event) {
    if ((pointPos = this.value.indexOf('.')) >= 0)
        $(this).attr("maxLength", pointPos+3);
    else
        $(this).removeAttr("maxLength");
});