Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# chrome的customvalidator问题_C#_Asp.net_Google Chrome_Customvalidator - Fatal编程技术网

C# chrome的customvalidator问题

C# chrome的customvalidator问题,c#,asp.net,google-chrome,customvalidator,C#,Asp.net,Google Chrome,Customvalidator,我有一个带有客户端验证功能的自定义验证器下拉列表,如下所示: <asp:DropDownList ID="lstResCity" runat="server"></asp:DropDownList> <asp:CustomValidator ID="cvResCity" runat="server" ControlToValidate="lstResCity" ErrorMessage="Please Select at le

我有一个带有客户端验证功能的自定义验证器下拉列表,如下所示:

<asp:DropDownList ID="lstResCity" runat="server"></asp:DropDownList>
        <asp:CustomValidator ID="cvResCity" runat="server" ControlToValidate="lstResCity"
            ErrorMessage="Please Select at least one city" ForeColor="Red" ClientValidationFunction="validateCities"
            ValidateEmptyText="true">*</asp:CustomValidator>

function validateCities(source, args) {debugger;
    args.IsValid = $("#<%=lstResCity.ClientID %> option:selected").length > 0;
}

*
函数validateCities(source,args){调试器;
args.IsValid=$(“#选项:选定”)。长度>0;
}
javascript函数是因为我在下拉列表中使用了mulitiselect jquery,所以我需要验证用户是否至少选择了一个城市


问题出在chrome客户端,未触发验证,且未显示此控件的验证摘要消息

我尝试使用args.IsValid=false;它在所有浏览器中都运行良好(验证为false)。你给我的JS代码对我来说永远是正确的。试着让你的JS变得简单,试一试ASP.NET发出的验证JS在所有浏览器中都能正常工作。所以应该是您的代码导致了问题。