JSFiddle - React, Tailwind, and code Playground

HTML

<form>
    <input type="text" onkeyup="this.value = (this.value[0] === '-') ? ('-' + this.value.replace(/[^0-9]/g, '')) : (this.value.replace(/[^0-9]/g, ''));" pattern="^-?\d+" />
    <input type="submit" />
</form>