asp.netvalidationcomparevalidator

CompareValidator error when value between 3 and 10


I have problem with CompareValidator. I need to validate input1 such that it is less than or equal to "Somepercentage" from database. The control keep showing error message when input1 is between 3-10 even when it is less than "Somepercentage". When input1 is more than 10, it works fine.

<asp:CompareValidator ID="Validator" runat="server" ErrorMessage="CompareValidator"  valueToCompare='<%# Eval("Somepercentage")%>' ControlToValidate="input1" Operator="LessThanEqual"></asp:CompareValidator>

Solution

  • I found the solution. add type="Double" into asp:comparevalidator tag.

    CompareValidator does not work with single digit