CompareValidator isn't working with more than 2 decimal places for Currency data-types

by Dominic Zukiewicz 5. June 2008 14:52

I used a ASP .NET CompareValidator to validate a floating point amount in a textbox.

While testing the application, I noticed that "0.05" would work, but "0.052", "0.0521", "0.05213" wouldn't? They were all valid numbers, but for some reason the validator was saying it wasn't?

Its turns out that theconfigured Currency data-type only allows the regional default of decimal places. Since the Regional Settings was for UK and the decimal places were 2, it wasn't technically a valid currency over 2 decimal places.

Instead I used the Double data-type to validate against, and then cast that to a decimal.

Hope this helps, as it totally baffled me!

Tags:

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar