这段JAVASCRIPT写地有错吗? 求救.
<script language= "javascript ">
<!--
function ClientValidate(source, arguments)
{
var ddl=document.getElementById( "DropDownList1 ");
for(var i=0;i <ddl.options.length;i++)
{
if(arguments.Value == ddl.options[i].Value)
{
arguments.IsValid=false;
return;
}
}
arguments.IsValid=true;
}
// -->
</script>
目的:验证一个TextBox的内容不能和DropDownList里的任何值相等,否则验证失败
但是好象无论输什么都是验证失败.怎样才可以达到目的?
aspx文件如下:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
<asp:CustomValidator ID= "CustomValidator1 " runat= "server " ErrorMessage= "ERROR " ClientValidationFunction= "ClientValidate "
ControlToValidate= "TextBox1 "> </asp:CustomValidator>
<asp:DropDownList ID= "DropDownList1 " runat= "server " Width= "174px ">
<asp:ListItem> 001 </asp:ListItem>
<asp:ListItem> 002 </asp:ListItem>
<asp:ListItem> 003 </asp:ListItem>
<asp:ListItem> abc </asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID= "