programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Saturday, August 23, 2014 RequiredFieldValidator validate to RadioButtonList RequiredFieldValidator(how to validate RadioButtonList):

In this article we learn how to validate a RadioButtonList using JavaScript in ASP.NET. As we know that JavaScript provides a way to validate a web page’s data on the client's computer before sending it to the web server.

Other Radiobuttonlist related  example in

To validate RadioButtonList in JavaScript:

function getCheckedRadioButton() 
    var radio = document.getElementsByName("RadioButtonList1");                           
    for (var i = 0; i < radio.length; i++) 
       if (radio[i].checked) { 
       alert("Radio button having value " + radio[i].value + " was checked."); // Show the checked value
       return true;
  alert("Not checked any radio button");    

Validating RadioButtonList:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Radiobuttonlist_validation.aspx.cs"
    Inherits="Radiobuttonlist_validation" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<script runat="server"> 
    protected void Button1_Click(object sender, EventArgs e)
        Label1.Text = "Select one : ";
        Label1.Text += RadioButtonList1.SelectedItem.Text.ToString();
<html xmlns="">
<head id="Head1" runat="server">
    <title> RequiredFieldValidator example: how to validate RadioButtonList</title>
    <form id="form1" runat="server">
        <h2 style="color: Green">
            RadioButtonList Validation in using C#</h2>
        <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Red"> 
        <br />
        <br />
        <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatColumns="3"
            ForeColor="Black" BorderColor="DarkBlue" BorderWidth="2">
        <asp:RequiredFieldValidator ID="ReqiredFieldValidator1" runat="server" ControlToValidate="RadioButtonList1"
            ErrorMessage="Select your favorite!"> 
        <br />
        <asp:Button ID="Button1" runat="server" ForeColor="Red" Text="Submit "
            OnClick="Button1_Click" Width="165px" />
</html> RequiredFieldValidator to RadioButtonList RequiredFieldValidator to RadioButtonList

Other related Post:

No comments:

Post a Comment