Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2008, 03:24 AM
Registered User
 
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validate Radiobuttonlist using Javascript

Hi i have a radiobutton list placed inside an update panel.I can get an alert with JavaScripting when the radiobuttonlist is not selected.but the problem is that when i check the radiobuttonlist and click the save button i get the same message.what's problem?.
how do i achieve this.

All suggestions are much appreciated

Thanks in advance

the javascript code given below

 <script language="javascript" type="text/javascript">
     function ValidateRadioTable()
{
var rb2 = document.getElementById('<%=rdTable.ClientID%>');
var radio_choice2 = false;
 for (counter2 = 0; counter2 < rb2.length; counter2++)
 {
  if (rb2[counter2].checked)
  {
   radio_choice2 = true;
   break;
 }
 }
 if (radio_choice2==false)
 {
  alert("Please select Table Booking Yes or No.")
    event.returnValue=false;
    return false;
 }
return false;
}

</script>

----------------------------
  <asp:RadioButtonList ID="rdTable" runat="server" AutoPostBack="True" Font-Size="10pt"
                                            RepeatDirection="Horizontal" Width="110px">
                                            <asp:ListItem>Yes</asp:ListItem>
                                            <asp:ListItem>No</asp:ListItem>

  </asp:RadioButtonList></td>


 
Old November 6th, 2008, 04:55 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I suggest you show the HTML generated by the ASP code in regards to the radio buttons. Then we can see whether the script should work or not.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript to validate a textbox abhishekkashyap27 Javascript 9 May 6th, 2008 02:41 AM
Putting JavaScript Events on RadioButtonList Items MikeSchnell ASP.NET 1.0 and 1.1 Basics 6 October 7th, 2007 08:16 PM
hi help me to write javascript to validate textbox karthikc85 XML 1 October 12th, 2006 03:12 AM
validate date javascript lcsgeek Classic ASP Basics 3 October 3rd, 2003 04:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.