❔ Number formatting issue
Hi all!
I'm currently dealing with an issue where number formatting is not working as intended. I'm using ASP.NET MVC and when I try to submit I form, form validation stops the request and it shows " The field ... must be a number". Whenever I change the numbers to for example 4.80, it submits the form, however it saves it as 480, so it doesn't include the comma correctly.
We've recently added Globalization/localization to our application and this seems to have caused the issue.
Code snippet of that:
I've previously solved the issue by forcing the culture, like this:
However, right now I'm not able to do that, as it makes use of the app.UseRequestLocalization(localizationOptions);. How would I force the culture to make use of a certain number seperator and ensure that it saves it correctly and not as a whole number?
7 Replies
Just to give some more info, the property that is bound to all the numbers is actually a decimal. I found out that this is best for saving things like prices. By using a decimal, I've also managed to solve the issues when globalization and localization wasn't installed yet.
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/Thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.No, the issue was not resolved yet.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.