Id想知道如何在更改下拉列表值后禁用验证器,而不必按提交:
<asp:DropDownList ID="ddlAttendance" DataTextField="name" DataValueField="Id" runat="server"
DataSourceID="sdsAppointmentStatuses" CssClass="form-control"
>
</asp:DropDownList>
<asp:TextBox CssClass="form-control" ID="txtAttendanceNotes" runat="server" Rows="2" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvNotes" runat="server" ErrorMessage="A Note is required with this status"
Display="Dynamic" CssClass="text-error" ControlToValidate="txtAttendanceNotes" Enabled="false"></asp:RequiredFieldValidator>
JavaScript
<script type="text/javascript">
function validate(vcontol, dropDownList) {
var returnStr = '<%=NotesData() %>';
var bb = JSON.parse(returnStr);
for (var i = 0; i < bb.length; i++)
{
if (dropDownList.value == bb[i]) {
vcontol.enabled = true;
}
}
}
</script>
答案 0 :(得分:0)
这里是解决相同问题的链接。将复选框替换为您的下拉值。 asp:RequiredFieldValidator validation based on conditions