Jose Saiz

Jose Saiz

  • 1.5k
  • 260
  • 103.9k

Help Aligning Error Message right next to TextBox

Feb 18 2022 5:40 PM

Hi Guys

I would like to display the error message right next to the input textbox instead below the input textbox or above the input textbox, this the code. I've tried using the <SPAN> TAG but I had no luck, can any help with CSS

<table width="100%" id="table1">
    <tr>
        <td align="right">
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator7" ControlToValidate="txtVendorPhone" ValidationGroup="fldGrpVal" runat="server" ErrorMessage="Telephone is required."> * </asp:RequiredFieldValidator>Telephone:</td>   
        <td align="left">       
                 <asp:TextBox ID="txtvendorPhone" CssClass="form-control" Width="120px" runat="server"></asp:TextBox>                                                                                                                                
                 <asp:RegularExpressionValidator ID="RegularExpressionValidator2" CssClass="level-message" ControlToValidate="txtVendorPhone" ValidationExpression="^[0-9]{10}$" ValidationGroup="fldGrpVal" runat="server" ErrorMessage="Invalid Phone Number"></asp:RegularExpressionValidator>                                                                                                    
        </td>
    </tr>
</table>

What I mean, when the user keystroke the invalid numeric value for the phone the RegularExpressionValidator will catch it and throws an error message "Invalid Phone Number" and I would like the error message to be shown right next to the input textbox (txtVendorPhone).

 

Thanks


Answers (2)