0

enter image description here enter image description here

Hello, I've been trying to get this to work for ages now and I've ran out of options. No matter what I try, the value for a double/decimal is always invalid according to the Jquery validator. This is a list of what I tried:

  • Set culture in web.config
  • Set culture in CurrentThread
  • Change type from Decimal to Double
  • Change input type from Number to Text
  • Use globalize.js
  • Use a custom regex fix found on here
  • Use a DecimalBinder found on here

Nothing, absolutely nothing fixes this error. I'd greatly appreciate if somebody could point out what I was doing wrong here.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
RayShawnOfNapalm
  • 210
  • 6
  • 20

1 Answers1

1

DisplayFormat.DataFormatString uses .NET's predefined formatting rules. In particular, the . (dot/period) is always interpreted to mean "the decimal point of the current culture", which in your case is ,, or comma.

If you want a literal dot separating the whole and fractional parts of the number, you need to escape it:

[DisplayFormat(DataFormatString = @"{0:0\.00}", ApplyFormatInEditMode = true)]
Ian Kemp
  • 28,293
  • 19
  • 112
  • 138