JSFiddle - React, Tailwind, and code Playground

HTML

<input type='number' class='number'>

JavaScript

$(".number").on('input', function () {
  this.value = this.value.replace(/e|E|\./g, ''); // Remove e, E, and period(.)
                if (this.value.length > 4) {
                    this.value = this.value.slice(0, 4);
                }
            });