Reputation: 31
I am working on a model (in a MVC3 project) that uses a latitude and longitude attributes, they are currently set as a [DataAnnotationsExtensions.Numeric]. But this causes a "The field Latitude must be a number." error when i enter a number with a comma (50,01) even if the user has a culture that uses this kind of annotation (nl-BE for example).
What i am asking if there is a way to configure [DataAnnotationsExtensions.Numeric] that it does allow comma with any kind of culture, or a better way to specify a number than [DataAnnotationsExtensions.Numeric]?
Upvotes: 0
Views: 613
Reputation: 3181
I'd go with RegularExpressions
[RegularExpression(@"^[0-9,-\.]+$", ErrorMessage = "Format is Invalid")]
Upvotes: 2