深入了解 ASP.NET 验证和Java脚本页面验证 Page_clientValidate()
此函数的工作是检查页面是否有效,如果任何验证器无效,则此函数返回 false,否则返回 true。
if (Page_ClientValidate()) {
// Page is Ok
//Submit it To The Server
return true
} else {
//Page is Not Valid
//Return False
return false
}
您可能缺少验证器上的验证设置或 js 上的其他错误。
您可以进行手动验证:
<script type="text/javascript" language="javascript">
/* Manual client-side validation of Validator Groups */
function fnJSOnFormSubmit() {
var isGrpOneValid = Page_ClientValidate("valGrpOne");
var isGrpTwoValid = Page_ClientValidate("valGrpTwo");
var i;
for (i = 0; i < Page_Validators.length; i++) {
ValidatorValidate(Page_Validators[i]); //this forces validation in all groups
}
//display all summaries.
for (i = 0; i < Page_ValidationSummaries.length; i++) {
summary = Page_ValidationSummaries[i];
//does this summary need to be displayed?
if (fnJSDisplaySummary(summary.validationGroup)) {
summary.style.display = ""; //"none"; "inline";
}
}
if (isGrpOneValid && isGrpTwoValid)
return true; //postback only when BOTH validations pass.
else
return false;
}
参考:
Page_ClientValidate() 与多个 ValidationGroups - 如何同时显示多个摘要?
Page_ClientValidate 正在验证多次。