【发布时间】:2014-07-04 07:23:57
【问题描述】:
我的代码如下
<asp:DropDownList ID="ddlFilter" runat="server" onchange="ShowHideSearchTextBox(this)">
<asp:ListItem Value="0">--Select--</asp:ListItem>
<asp:ListItem Value="customer_name">Customer Name</asp:ListItem>
<asp:ListItem Value="order_number">Order Number</asp:ListItem>
<asp:ListItem Value="Pending">Dispatch Pending</asp:ListItem>
<asp:ListItem Value="Done">Dispatch Done</asp:ListItem>
</asp:DropDownList>
<script type="text/javascript">
function ShowHideSearchTextBox(me) {
var searchBox = document.getElementById("searchBox");
var validator = document.getElementById(" <%= RequiredFieldValidator1.ClientID%> ");
if (me.value == "Pending" || me.value == "Done") {
ValidatorEnable(validator, false);
searchBox.style.display = "none";
}
else {
ValidatorEnable(validator, true);
searchBox.style.display = "block";
}
}
</script>
无论我在下拉菜单中选择什么值,我的验证器始终处于活动状态。我错过了什么?
编辑
validator 的值即将到来null
【问题讨论】:
标签: javascript asp.net validation