Microsoft KB Archive/815187

= BUG: RangeValidator and CompareValidator Controls Do Not Recognize Currency and Double Data =

Article ID: 815187

Article Last Modified on 4/30/2003

-

APPLIES TO


 * Microsoft ASP.NET 1.0
 * Microsoft ASP.NET 1.1

-





SYMPTOMS
When you validate the Currency data or the Double data in an ASP.NET application by using the RangeValidator control or the CompareValidator control, and the data has a decimal point at the beginning or at the end, you receive the error message as mentioned in the ErrorMessage property of the Validator control.



CAUSE
This problem occurs because RangeValidator and CompareValidator do not recognize input data of type Currency if the data has a decimal point at the beginning or at the end (for example, 25. or .25). Also, when input data has a decimal point at the end (for example, 25.), RangeValidator and CompareValidator do not recognize it as valid input data of type Double.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 In Microsoft Visual Studio .NET, create a new ASP.NET Web Application project by using Visual Basic .NET or Visual C# .NET. By default, WebForm1.aspx is created.  Right-click WebForm1.aspx, and then click View HTML. Replace the existing code with the following sample code to add a TextBox control, a RangeValidator control, and a CompareValidator control: <%@ Page %> <!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot; >   WebForm2     <asp:RangeValidator id=&quot;RangeValidator1&quot; runat=&quot;server&quot; ErrorMessage=&quot;Double-RangeValidator&quot; ControlToValidate=&quot;TextBox1&quot; Type=&quot;Double&quot; MaximumValue=&quot;233&quot; MinimumValue=&quot;0&quot;></asp:RangeValidator> <asp:CompareValidator id=&quot;CompareValidator1&quot; runat=&quot;server&quot; ErrorMessage=&quot;Double-CompareValidator&quot; ControlToValidate=&quot;TextBox1&quot; Operator=&quot;GreaterThan&quot; Type=&quot;Double&quot; ValueToCompare=&quot;0&quot;></asp:CompareValidator> <asp:RangeValidator id=&quot;RangeValidator2&quot; runat=&quot;server&quot; ErrorMessage=&quot;Currency-RangeValidator&quot; ControlToValidate=&quot;TextBox1&quot; Type=&quot;Currency&quot; MaximumValue=&quot;244&quot; MinimumValue=&quot;0&quot;></asp:RangeValidator> <asp:CompareValidator id=&quot;CompareValidator2&quot; runat=&quot;server&quot; ErrorMessage=&quot;Curency-CompareValidator&quot; ControlToValidate=&quot;TextBox1&quot; Operator=&quot;GreaterThanEqual&quot; Type=&quot;Currency&quot; ValueToCompare=&quot;0&quot;></asp:CompareValidator> <asp:Button id=&quot;Button1&quot; runat=&quot;server&quot; Text=&quot;Button&quot;></asp:Button> </HTML> </li> On the Debug menu, click Start to run the application.</li> Type 25. in the text box, and then click Button. Verify that the validation error messages occurred for data types Double and Currency.</li> Type .24 in the text box, and then click Button. Verify that the validation error messages occurred for the Currency data type.</li></ol>

<div class="references_section">