如何使用C#在客户端验证多个RadioButtonList [英] How to validate multiple RadioButtonList on client side using C#

查看:115
本文介绍了如何使用C#在客户端验证多个RadioButtonList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的aspx页面中有十个RadioButtonList。我想在点击提交按钮之前/之后验证它们中的每一个。 Javascript也可以和我一起工作。任何人都可以帮忙吗?



提前致谢。

I have ten RadioButtonList in my aspx page. I want to validate each of them before/on clicking the submit button. Javascript could also work with me. Can anyone help?

Thanks in advance.

推荐答案

在javascript中使用'args.IsValid'验证是否检查了radiobuttonlist中的任何单选按钮..





函数ValidateModuleList(source,args){

var gridview = document.getElementById('<%= grdmygridview.ClientID%>');

if(gridview!= null){

document.getElementById( '<%= lblMessage.ClientID%>')。style.display ='inherit';

args.IsValid = true;

}

else

{

document.getElementById('<%= lblMessage.ClientID%>')。style.display ='none';

args.IsValid = false;

}

}



示例代码.. < br $> b $ b





根据需要编辑条件并将此函数放在你的列表下面的customvalidator中..



(ClientValidationFunction =ValidateModuleList)
use 'args.IsValid' in javascript to validate if any radio button in radiobuttonlist is checked..


function ValidateModuleList(source, args) {
var gridview = document.getElementById('<%= grdmygridview.ClientID %>');
if (gridview != null) {
document.getElementById('<%= lblMessage.ClientID %>').style.display = 'inherit';
args.IsValid = true;
}
else
{
document.getElementById('<%= lblMessage.ClientID %>').style.display = 'none';
args.IsValid = false;
}
}

sample code..



edit conditions as u need and put this function in customvalidator below ur list..

(ClientValidationFunction="ValidateModuleList")


这篇关于如何使用C#在客户端验证多个RadioButtonList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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