如何在单选按钮中设置必填字段验证器 [英] how to set Required Field Validator in Radio button

查看:881
本文介绍了如何在单选按钮中设置必填字段验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have radion button with same group name, and I would like to validate and it is just required field.

My questions, I have over 100 of this type of validation in different ascx control.
I am thinking to right generic one so I can use it globally. Can you show me how to do that? For calling  the object/class, I prefer to do  that on aspx. This is aspx/C# web app.

Thanks

 <asp:RadioButton ID="rdoArrestedYes" AutoPostBack="true" Text="Yes" GroupName="Arrest" runat="server" />
                                

                                <asp:RadioButton ID="rdoArrestedNo" GroupName="Arrest" Text="No" runat="server" />
                                
                                <asp:RequiredFieldValidator ID="rfvArresed" runat="server" 

                            ControlToValidate="Arrest" ErrorMessage="*" ForeColor="Red" 

                            ValidationGroup="ExtraCurriculam">

推荐答案

使用这个java脚本代码





use this java script code


<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
<title>Validate asp.net radiobuttonlist in JQuery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">


document )。ready( function (){
(document).ready(function() {


' #btnSubmit')。click( function (){
if
('#btnSubmit').click(function() { if (


这篇关于如何在单选按钮中设置必填字段验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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