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

any possibility to enter negative (-) mark in the input

Open slcoder opened this issue 4 years ago • 10 comments

Hi

First of all, thank you very much for this module, it really helped for me.

I'm having an issue of users always attempting to enter (-) mark when they want to add negative value to input, unfortunately, now users have to add numbers and enter (-) mark towards the end, which is not practical.

Any suggestion or help to sort this out?

Thanks

slcoder avatar May 29 '20 14:05 slcoder

Hi @slcoder,

At the moment we have the changeToNegative method that doesn't allow a negative mask to be applyed to a empty rawValue. To make it work we would need a temp attribute to hold the negative decision and apply it to the first number that comes after it, or, we could set a negative default value when the user types the minus button, but that seems odd to me.

I believe we could define that as a feature to be built. (as a config property)

What do you think?

This is the actual method:

changeToNegative(): void {
      if (this.options.allowNegative && this.rawValue != "" &&
          this.rawValue.charAt(0) != "-" && this.value != 0) {
          // Apply the mask to ensure the min and max values are enforced.
          this.rawValue = this.applyMask(false, "-" + this.rawValue);
      }
}

nbfontana avatar May 29 '20 16:05 nbfontana

Hi @nbfontana

Thank you for a prompt response.

Yes, I think your first approach would be handy., Are the changes releasing soon?

--my html---- I have configured my input as :

 <input matInput [(ngModel)]="element.amount" currencyMask  
              [options]="{ allowNegative: true }">

now users able to add minus value into the textbox - this is great

my actual issue is: the user does not allow to enter minus mark at the start of the textbox and enter the value, it only allows enter some value and enter a minus mark, that's is kind of odd practice I believe.

Really appreciate your help on this.

Thanks

slcoder avatar May 29 '20 20:05 slcoder

I've tried this function and it seems works

changeToNegative() {
        if (this.options.allowNegative && this.rawValue != " " && this.rawValue.charAt(0) != "-" && this.value != 0) {
            // Apply the mask to ensure the min and max values are enforced.
            if (this.rawValue == "" ||this.rawValue == "-"){
                this.rawValue ="-"
            }else{
                this.rawValue = this.applyMask(false, "-" + this.rawValue);

            }
        }
    }

sheta-exin avatar Jun 22 '20 08:06 sheta-exin

Any news regarding integration of this fix?

In Germany it's typical to type the minus sign at first - so it would be of great help to have this fix or a bybass.

Besides this I'm very happy with ngx-currency because it works perfect for me.

udamken avatar Oct 21 '20 12:10 udamken

Any update on this, as I also have different geo graphical users requiring the need to enter "-" first before the numeric value?

veraw avatar Feb 04 '21 07:02 veraw

Any fix to this in the near future?

ozgeengin avatar May 31 '21 14:05 ozgeengin

Any fix to this in the near future?

antonioclaudioneiva avatar Sep 22 '21 23:09 antonioclaudioneiva

¿Alguna solución encontrada?, tengo el mismo problema

Sebas15897 avatar Nov 26 '21 16:11 Sebas15897

I've tried this function and it seems works

changeToNegative() {
        if (this.options.allowNegative && this.rawValue != " " && this.rawValue.charAt(0) != "-" && this.value != 0) {
            // Apply the mask to ensure the min and max values are enforced.
            if (this.rawValue == "" ||this.rawValue == "-"){
                this.rawValue ="-"
            }else{
                this.rawValue = this.applyMask(false, "-" + this.rawValue);

            }
        }
    }

where to put this function, please?

ElChouaib avatar Nov 29 '21 14:11 ElChouaib

hello! any updates on this?

IvanHrushevich avatar Apr 19 '22 10:04 IvanHrushevich

bump

DywiTom avatar Nov 17 '22 08:11 DywiTom

Hi! Any updates? I also need that.

ArturQuirino avatar Nov 29 '22 16:11 ArturQuirino

Partially solved by https://github.com/nbfontana/ngx-currency/pull/99 and added to a new 3.0.0 npm version.

Will prob generate side-effects. It works like a charm with the default FINANCIAL input mode, but we prob see more bugs with the other type

nbfontana avatar Nov 30 '22 23:11 nbfontana