Best way to validate currency input?
- by Abe Miessler
I have created the TextBox and CompareValidator below which I thought would allow input in the following forms:
5
5.00
$5.00
Unfortunately it's not allowing the version with the dollar sign in it. What is the point of doing a type check against currency if you don't allow the dollar sign? Is there a way to allow this symbol?
<asp:TextBox ID="tb_CostShare" runat="server" Text='<%# Eval("CostShare", "{0:$0.00}")%>' CausesValidation="true" />
<asp:CompareValidator ID="vld_CostShare"
runat="server"
ControlToValidate="tb_CostShare"
Operator="DataTypeCheck"
Type="Currency"
ValidationGroup="vld"
ErrorMessage="You must enter a dollar amount for 'Cost Share'." />