Backspace isn't working in the input field in Vue JS (REGEX)

Viewed 110
  <vs-input
                  :value="contract.value"
                  :class="isMobileOnly ? 'w-full' : 'w-1/2'"
                  class="mx-auto"
                  type="number"
                  :id="`value-${index}`"
                  onkeydown="
                  return event.keyCode !== 69 && /^-?\d*\.?\d{0}$/.test(this.value)"
                  :placeholder="contract.value === 0 ? undefined : 'Value'"
                  @change="changeValue(index)"
                />

I want the input field to restrict to only one - sign but I can enter 2 - signs. Also, when I input number after the decimal point, I cannot use the backspace key. Backspace works fine when there's no number after decimal point

Backspace key doesn't work after you enter a number after a point

Backspace key doesn't work

I want to be able to enter only one minus sign not 2, in the start only

I want to be able to enter only one minus sign not 2

0 Answers
Related