DataAnnotationsExtensions
DataAnnotationsExtensions copied to clipboard
Numeric/Range interaction
[From Blog Comments, VincentG]
Hi Sir,
I am using your extensions for an ASP MVC3 VB project, and I really like the NumericAttribute extension, specifically because it can validate numeric strings with commas.
However when I combine NumericAttribute with, say, Range (built-in) or the extension's Min or Max, a weird thing happens. The Numeric test passes, but the range fails perhaps because of the comma.
In your sample site, for example, the MaxTenAndAHalf field, if you input -100000, it works. If you input -x, the correct error message appears: "The field MaxTenAndAHalf must be a number." Then, if you try -100,000... the error becomes: "The field MaxTenAndAHalf must be less than or equal to 10.5."
The same thing happens when I try to use the built-in Range annotation with the extension's Numeric attribute. As I would like to include commas in my application, is there any solution for the Range check to allow commas as well?
Thanks and have a nice day!