3

I´m having a problem when trying to use a view Model that as a decimal property. Because my decimal region/culture format uses "," and not "." as decimal separator.

When I try to post that model, I get the following error:

The value xxx is not valid for the "field".

I´m using jquery.unobstrusive and jquery.validation. So when I make the submit the model get validated and a error is shown an a label with the error above.

The thing is, the property does not have any kind of attributes (Required,Regex,Range). So that error is produced by the middleware/framework when trying to parse the string to decimal.

If I type a decimal like: 40.05 the form submit with success.

If I type a decimal like: 40,05 the form submit fails with the above error.


I have already read about Globalization at:

https://docs.asp.net/en/latest/fundamentals/localization.html#globalization-and-localization-terms

but could not find the "path" trought setting my globalization culture. At MVC4/5 we were used to add a web.config tag at system.web and that's it. But at MVC6 that doesn´t seem to be the way.

Any tips?

Tseng
  • 61,549
  • 15
  • 193
  • 205
Alan Araya
  • 701
  • 1
  • 12
  • 27
  • These questions could give you some idea http://stackoverflow.com/questions/14513468/detect-decimal-separator http://stackoverflow.com/questions/3135569/how-to-change-symbol-for-decimal-point-in-double-tostring – Yang You Jun 09 '16 at 00:44
  • to me it sounds like you are asking how to [configure the default culture](http://stackoverflow.com/questions/37709060/how-to-change-the-default-culture) – Joe Audette Jun 10 '16 at 17:38

0 Answers0