Inputmask icon indicating copy to clipboard operation
Inputmask copied to clipboard

Percentage: Can't delete 0.00 %

Open cpuneetvyas opened this issue 8 years ago • 4 comments

I am using inputmask percentage to allow user to enter percentage value between 0.00 till 1000.00. However when user presses 0. and tabs out the input field gets populated to 0.00% which is what we require. We also require user to delete this 0.00 value however it seems delete key is not working or disabled by plugin.

Could you please tell how to allow user to delete this 0.00 value by using backspace or delete key. Please find source code

cpuneetvyas avatar Sep 21 '17 12:09 cpuneetvyas

Could any one help in this regard and provide some pointers?

cpuneetvyas avatar Sep 25 '17 06:09 cpuneetvyas

Any one can please point me towards some solution?

cpuneetvyas avatar Oct 03 '17 07:10 cpuneetvyas

I'm working on a solution,but I only have little time to spend. Hopefully a fix soon

RobinHerbots avatar Oct 04 '17 19:10 RobinHerbots

My workaround:

const currencyMask = createMask({
  alias: 'numeric',
  autoUnmask: true,
  unmaskAsNumber: true,
  radixPoint: ',',
  groupSeparator: '.',
  digits: 2,
  digitsOptional: false,
  showMaskOnHover: false,
  onKeyDown:(event: KeyboardEvent) => {
    if (event.key == 'Delete' || event.key == 'Backspace') {
      let el = event.target as HTMLInputElement;
      if (el.value == '0') el.value = '';
    }
  }
});

DywiTom avatar Feb 03 '22 16:02 DywiTom