ASP compareValidator's error message won't disappear after a valid input in entered

1.3k views Asked by At

I have a form for adding some values to my DB. One of the input requires a Integer value, so on that TextBox I have two validators, an RequiredFieldValidator and an CompareValidator. The problem is that when I click on the input the first time ( or I got there with tab) the error message is displayed an it will never disappear, even if I enter a valid input.

<asp:Label ID="label4" runat="server" Text="label4"></asp:Label>
<asp:TextBox ID="textBox4" runat="server" style="width: 170px; margin: 5px 0;"></asp:TextBox>
<asp:RequiredFieldValidator ID="requiredFieldValidator4" runat="server" 
    ErrorMessage="*" ControlToValidate="textBox4" Display="Dynamic" 
    ForeColor="Red" ValidationGroup="1"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="compareValidator4" runat="server"
    ErrorMessage="*" ControlToValidate="textBox4"
    Type="Integer" Operator="DataTypeCheck" Display="Dynamic" 
    ForeColor="Red" ValidationGroup="1">
</asp:CompareValidator>

Above is my code for that input.

1

There are 1 answers

1
Miguel Ruiz On

Have you already tried adding the property "ControlToCompare" to your compare validator?, for reference take a look of this post: http://forums.asp.net/t/1842937.aspx?CompareValidator+doesn+t+disappear+when+entering+the+correct+value