【发布时间】:2010-03-17 13:21:37
【问题描述】:
我正在使用 AJAX 级联下拉列表,但想添加事件验证,例如比较验证器。
由于级联下拉列表需要禁用页面事件验证,因此进行验证的最佳方法是什么?
谢谢
安迪
验证尝试:
我曾尝试使用调用 Javascript 函数的自定义验证器,但它似乎没有获得控制权。我收到以下错误Microsoft JScript runtime error: Object required
function ValidateCostCentCat(source, arguments)
{
var countryList = document.getElementById("ddlCategory");
if (null != countryList)
{
var iValue = countryList.options[countryList.selectedIndex].value;
if (iValue == "Select Category")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
}
自定义验证器的标记是
<asp:CustomValidator ID="valcustCategory" runat="server" CssClass="error" Display="Dynamic" ValidationGroup="DirectHire" ClientValidationFunction="ValidateCostCentCat"
ErrorMessage="Please select a Cost Centre Category from the drop down list provided.">!</asp:CustomValidator>
【问题讨论】:
标签: asp.net ajax validation