RayShawnOfNapalm
RayShawnOfNapalm

Reputation: 210

The value is not valid for double/decimal

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:

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

Upvotes: 0

Views: 3008

Answers (1)

Ian Kemp
Ian Kemp

Reputation: 29839

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)]

Upvotes: 1

Related Questions