禁用一些ASP.Net验证控件,当复选框被选中 [英] Disable some ASP.Net validation controls when a checkbox is checked

查看:266
本文介绍了禁用一些ASP.Net验证控件,当复选框被选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用老式的ASP.NET验证(啊)的结帐过程。我有一个复选框 - 我会用我的信用卡详情来电。 - 如果选中我需要禁用的信用卡号码所需的字段校验和CC验证在客户端上,并在回发。

I'm using old fashioned ASP.NET validation (ugh) for a checkout process. I have a checkbox -"I'll call with my credit card details"-. If checked I need to disable the required field validator and cc validator for the credit card number both on the client and on the Postback.

如何做到这一点呢?

推荐答案

您可以禁用验证客户端(在JavaScript):

You can disable the validators client-side (in javascript):

function disable(validatorId)
{
   var validator = document.getElementById(validatorId);
   ValidatorEnable(validator, false);
}

在哪里validatorId是被禁止的验证程序的clientID的。见<一href=\"http://www.willasrari.com/blog/use-client-side-javascript-to-disable-aspnet-validators/000289.aspx\">this页面一个完整的例子。

这篇关于禁用一些ASP.Net验证控件,当复选框被选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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