Search code examples
asp.netcomparevalidationcomparevalidator

CompareValidator error message position


I have CompareValidator control in my webpage and it works perfectly. I use it to validate date which user can enter in textbox. Problem is, that error message is shown in the right of the textbox. Is there any way to show it under the textbox?
Control code is like this:

<asp:CompareValidator
   runat="server"
   ID="myValidatorID"
   Type="Date"
   Operator="DataTypeCheck"
   ControlToValidate="DateTextBoxID"
   ErrorMessage="Date is not valid">
</asp:CompareValidator>

Solution

  • Try this

    <table>
    
    <tr>
    <td><asp:TextBox runat="server" ID="txtBox"/></td>
    <td>another control</td>
    <td>another control</td>
    </tr>
    <tr>
    <td><asp:CompareValidator
           runat="server"
           ID="myValidatorID"
           Type="Date"
           Operator="DataTypeCheck"
           ControlToValidate="DateTextBoxID"
           ErrorMessage="Date is not valid">
        </asp:CompareValidator>
    </td>
    <td></td>
    <td></td>
    <tr>
    
    </table>