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

Append decimal separator and places to the input when the user writes a number and there's no number present there. #696

Open
dantronik-bugreporting opened this issue Jul 17, 2020 · 2 comments

Comments

@dantronik-bugreporting
Copy link

I'm trying to create the autonumeric textbox, so that the decimal separator and the decimal places are appended whenever the user writes a number in the input and it's empty.

Current behavior

Decimal separator and decimal places are not appended when the user first writes a number in the textbox.

Expected behavior

Decimal separator and decimal places are appended to the user's input.

Steps to reproduce the problem

  1. Use autoNumeric version 4.1.0
  2. I instantiated the AutoNumeric textbox with the following options:
let autoNumericOptions = [
    'commaDecimalCharDotSeparator',
    {
        decimalPlaces: 2,
        decimalPlacesShownOnFocus: 2,
        formulaMode: true
    }
];
new AutoNumeric($el, autoNumericOptions);
  1. Decimal separator and decimal places are appended to the user's input.

Link to live example (ie. Codepen)

https://codepen.io/dantronik-markus/pen/YzwJgVW

tbh, I assumed that decimalPlacesShownOnFocus would take care of it, however, it seemingly does not. Also, if there's anything in the documentation regarding this issue and I missed it, I'm sorry.

@AlexandreBonneau
Copy link
Member

The decimal character and the decimal places (2 by default) are appended on blur.
This behavior is being used to prevent messing with the user input ; we do not want to surprise the user by drastically changing the input value (by adding 3 characters on his first input).

This is why we display by default the currency characters on hover/focus for instance.

What would be your use case for this behavior?

@dantronik-bugreporting
Copy link
Author

The use case for the behaviour is making people aware of the fact that they can enter decimal numbers. We're in the process of porting over a Silverlight application to a web app and I'm trying to emulate the behaviour in that app, and that behaviour was that it would automatically append ".00" (or rather ",00" in German) in order to show that decimal numbers are allowed (that is, only if the input is empty upon entering the first number).

It's not a big deal anyway if this can't be added. I think the behaviour of the textbox is good enough as it is.

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

2 participants