I am using asp validation controls to validate a form with some <asp:textbox>
s in my page.Giving an error message for a not-validated textBox is pretty easy using the error message attribute in the <asp:validation>
controls.The thing I want to do is that I want my textBoxes to become red when they are not validated.To achieve this goal (I'm guessing that) I need to detect the not-validated textbox and give it a special style using css.But I have no idea how!
for example look at this code:
<form id="form1" runat="server">
<div>
<div>
username: <br />
<asp:TextBox ID="txtboxUserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameReq" ControlToValidate="txtboxUserName" ErrorMessage="username is required!!!" SetFocusOnError="true" runat="server">
</asp:RequiredFieldValidator><br />
password: <br />
<asp:TextBox ID="txtboxPassword" TextMode="Password" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordReq" ControlToValidate="txtboxPassword" ErrorMessage="password is required!!!!" SetFocusOnError="true" runat="server"></asp:RequiredFieldValidator><br />
<asp:Button ID="submitButton" Text="submit" runat="server" />
</div>
</div>
</form>
I want the username and password textboxes to become red themselves when the user doesn't type anything in them!(To be clear,I want to do this on other types of validations too,and the code above is just an example)