我有一个TextBox输入元素,它具有requiredFieldValidator:
<div> <label>First name</label> <asp:requiredFieldValidator ID="requiredFieldValidatorFirstname" runat="server" ErrorMessage="required" ControlToValidate="TextBoxFirstname"></asp:requiredFieldValidator> <asp:TextBox ID="TextBoxFirstname" runat="server"></asp:TextBox> </div>
当TextBox在提交时为空时,我想将类’form-error’添加到父Div:
<div class="form-error"> <label>First name</label> <asp:requiredFieldValidator ID="requiredFieldValidatorFirstname" runat="server" ErrorMessage="required" ControlToValidate="TextBoxFirstname"></asp:requiredFieldValidator> <asp:TextBox ID="TextBoxFirstname" runat="server"></asp:TextBox> </div>
这是可能的,如果是这样 – 我该怎么办?