Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
slcoder opened this issue May 29, 2020 · 13 comments
Closed

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

slcoder opened this issue May 29, 2020 · 13 comments

Comments

@slcoder
Copy link

slcoder commented May 29, 2020

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

@nbfontana
Copy link
Owner

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);
      }
}

@slcoder
Copy link
Author

slcoder commented May 29, 2020

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

@sheta-exin
Copy link

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);

            }
        }
    }

@udamken
Copy link

udamken commented Oct 21, 2020

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.

@veraw
Copy link

veraw commented Feb 4, 2021

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

@ozgeengin
Copy link

Any fix to this in the near future?

1 similar comment
@antonioclaudioneiva
Copy link

Any fix to this in the near future?

@Sebas15897
Copy link

Sebas15897 commented Nov 26, 2021

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

@ElChouaib
Copy link

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?

@IvanHrushevich
Copy link

hello! any updates on this?

@DywiTom
Copy link

DywiTom commented Nov 17, 2022

bump

@ArturQuirino
Copy link

Hi! Any updates? I also need that.

@nbfontana
Copy link
Owner

nbfontana commented Nov 30, 2022

Partially solved by #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests