ASP.NET验证摘要:如何使用JavaScript禁用验证程序? [英] ASP.NET Validation Summary: How to disable validator with JavaScript?

查看:54
本文介绍了ASP.NET验证摘要:如何使用JavaScript禁用验证程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用JavaScript禁用ASP.NET RequiredFieldValidator。其实我正在使用以下代码:

I want to disable a ASP.NET RequiredFieldValidator with JavaScript. Actually I'm using the following code:

function doSomething() 
{ 
  var myVal = document.getElementById('myValidatorClientID'); 
  ValidatorEnable(myVal, false);  
} 

这会禁用验证器。
但我的问题是,我正在使用ValidationSummary。即使我禁用验证器,此摘要也会显示验证消息。

This disables the validator. But my problem is, that I'm using a ValidationSummary. And this summary shows the validation message, even if I disable the validator.

有人可以告诉我,如何在ValidationSummary中禁用验证器吗?

Can someone tell me, how to disable the validator in the ValidationSummary too?

推荐答案

解决方案是在禁用验证器后添加对ValidationSummaryOnSubmit()的调用。

The solution is to add a call to ValidationSummaryOnSubmit() after you disable the validator.

function doSomething()  
{  
    var myVal = document.getElementById('myValidatorClientID');  
    ValidatorEnable(myVal, false);   
    ValidationSummaryOnSubmit();
}

您可以找到名为的文件WebUIValidation.js 在您的开发计算机上,其中包含ASP.NET验证过程使用的客户端JavaScript函数。这些函数名称很好,通常很容易弄清楚每个函数的作用。

You can find a file called WebUIValidation.js on your development computer, which contains the client side JavaScript functions used by the ASP.NET validation process. The functions are well named and it's generally fairly easy to figure out what each of them do.

这篇关于ASP.NET验证摘要:如何使用JavaScript禁用验证程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆