JSFiddle - React, Tailwind, and code Playground

HTML

<input class="number" type="text" value="" onkeypress="return isNumberKey(event)" onkeyup="tronc(this)"/>
<input type="text" value="44" />http://jsfiddle.net/e0orb0qq/22/#jshint

JavaScript

isNumberKey = function (evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode

    var removeKey = [9, 37, 39, 46, 8];
    if (removeKey.indexOf(charCode) > -1) {
        return true;
    }
    
    if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46) {
        return false;
    }
    return true;
}


tronc = function (t) {
    var input = t.value;
    if ((input.indexOf('.') != -1) && (input.substring(input.indexOf('.')).length > 3)) {
        t.value = input.substring(0, input.length-1);
    }   
}