我正在使用Page_ClientValidate进行验证。
即使没有无效输入,也会返回false。
function PageValid() {
var valid = Page_ClientValidate('save');
alert(valid);
if (valid == true) {
$('.mydiv').hide();
}
}
此处'save'是验证组。请帮帮我们。
谢谢, Rajbir
答案 0 :(得分:13)
浏览ASP.NET Validation in Depth和Java script page validation Page_clientValidate()
此功能的作业是检查页面是否有效(如果有的话) 验证器无效此函数返回false,否则返回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() with multiple ValidationGroups - how to show multiple summaries simultaneously?
Page_ClientValidate is validating multiple times.