开发者

Why can't I validate values with the $ symbol in it?

I am using a CompareValidator to check user input on one of my forms but for some reason it will not allow me to enter a dollar sign.

According to MSDN the currency data type in the compare validator allows:

A decimal data type that can contain currency symbols.

I am using the control below to validate:

<asp:CompareValidator ID="vld_Cash" runat="server" ControlToValidate="CashTextBox" Type="Currency" Operator="DataTypeCheck" ValidationGroup="vld_Update" ErrorMessage="The value entered for 'Cash' must be in a number format.  Do NOT include dollar signs.  Example开发者_C百科s: 500 or 500.00" />

I also added the following to my web.config just to be sure:

<globalization culture="en-US" uiCulture="en-US"/>

But it still says any input with a $ in it is invalid. Am I missing something here?


The last comment in this thread shows why and gives you some ideas:

Currency Validator

An article dedicated to this:

ASP.Net: Validating a TextBox with a Dollar Sign (suggests using a RegularExpressionValidator).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜