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

how to force adding commas to a numeric value #6

Open
appilux opened this issue Aug 11, 2022 · 7 comments
Open

how to force adding commas to a numeric value #6

appilux opened this issue Aug 11, 2022 · 7 comments

Comments

@appilux
Copy link

appilux commented Aug 11, 2022

hi tnx for the great work!
im struggling to define a template for forcing value to be comma separated with any number of digits
can u guide me on that?

@SalahAdDin
Copy link

SalahAdDin commented Aug 20, 2022

hi tnx for the great work! I'm struggling to define a template for forcing values to be comma separated with any number of digits can u guide me on that?

It is more related to your regex pattern, you can search about it on Google, and test them on regex101-like websites.

@vahidreza
Copy link

vahidreza commented Aug 21, 2022

Tnx but regex is for validation.
What i need is a mask which puts comma between every 3 digits as the user inputs the number. Any idea how that's achievable?

@SalahAdDin
Copy link

Tnx but regex is for validation. What I need is a mask that puts a comma between every 3 digits as the user inputs the number. Any idea how that's achievable?

Again, regex patterns.

@dimitrov-adrian
Copy link
Owner

Tnx but regex is for validation. What i need is a mask which puts comma between every 3 digits as the user inputs the number. Any idea how that's achievable?

Try ^([0-9]{1,3}\.)*[0-9]{1,3}?$

As @SalahAdDin pointed, regex is the key

@appilux
Copy link
Author

appilux commented Aug 27, 2022

@dimitrov-adrian tnx,
your proposed regex is passed if i check a number like 444,444 with it using normal regex checking procedure,
but putting it on the interface, it puts a comma when i enter 5 fours, in the wrong place (it shows it as 444,44 instead of 44,444) and when entering 6 fours it turns into red and adds another comma at the end (444,444,).
so basically the comma position is wrong and the number of digits cannot be an even number using this regex.
any idea how this can be fixed?

@dimitrov-adrian
Copy link
Owner

I just tried it and yes, this is an issue. I believe it's related to the inputmask library that is used. I'll investigate more on this.

@zbjdonald
Copy link

Any updates?

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

No branches or pull requests

5 participants