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在所有浏览器中都能正常工作。所以应该是您的代码导致了问题。