ngx-mask icon indicating copy to clipboard operation
ngx-mask copied to clipboard

How to mask optionally negative number with digits after coma (-2,2321; 2,321; -123; 232)?

Open Falynsky opened this issue 4 years ago • 0 comments

Hi,

Is there any posible way to create a mask for optionally negative number with optional unlimited digits after coma?

My inputs:

  1. -12345..9.2
  2. -1,222222222222
  3. 12345,2
  4. 111111111111.2
  5. 1234567
  6. -1

I tried this pattern, but i can't type dot if i dont type '-' character before

           mask="M9*D9*"
           [patterns]="numericCustomPattern"
           [allowNegativeNumbers]="true"
           [dropSpecialCharacters]="false"
  numericCustomPattern = {
    'M' : { pattern : new RegExp('-?') },
    '9' : { pattern : new RegExp('[0-9]') },
    'D' : { pattern : new RegExp(/[.,]/g) }
  };

Falynsky avatar Jan 21 '21 15:01 Falynsky