JSFiddle - React, Tailwind, and code Playground

HTML

<input name="price" style="height:20px;">

JavaScript

$('[name="price"]').bind("change keyup input", function() {
  pricecheck = '^(\\-)?\\d{1,9}(\\.\\d{0,2})?$';
  var regex = new RegExp(pricecheck, 'g');
  if (!regex.test(this.value)) {
    console.log('not in regex');
    this.value = this.value.slice(0, -1);
  }
});