我正在使用以下命令在jquery中禁用必需的验证器,这摆脱了必需的标签,但实际必需的仍处于启用状态,并且未执行按钮单击操作
var $checkboxes = $(".parent input[type='radio']"); // cache for better performance
$checkboxes.change(function () {
var $this = $(this), currentIndex = $checkboxes.index($this); // get current changed checkbox's index
if (currentIndex === 1) {
if (this.checked) {
var valEmail = $("[id*=RequiredFieldValidator1]");
ValidatorEnable(valEmail[0], false);
return true;
} else {
}
}
});
因此,当我单击特定的单选按钮时,应关闭验证器,它会删除“必填”标签,但实际上并不需要删除必须填写文本框的情况
<asp:TextBox runat="server" ID="TextBox1" CssClass="text" Width="100%" Height="18px" EnableViewState="false" ViewStateMode="Disabled" />
<asp:RequiredFieldValidator Visible="true" Display="Dynamic" Enabled="false" ViewStateMode="Disabled" EnableViewState="false" ControlToValidate="TextBox1" runat="server" ID="RequiredFieldValidator1" SetFocusOnError="True" CssClass="vRequired" ErrorMessage="<br />Required<br />" />