Link to home
Start Free TrialLog in
Avatar of jazz__man
jazz__man

asked on

Loop through a RadioButtonList using javascript, in order to validate if a selection has been made.

Hi,

I have a radiobuttonlist which I have to validate using javascript. I know there are a million better ways and easier ways to do this using server side code, however specific to the application I am working on I need to do this in javascript.

Having searched and found many "Solutions" to this problem, I have had none that have worked.
I realy would appreciate some feedback on the easiest way to do this.
All I need to do us check if an item has been selected or not.

Cheers

ASKER CERTIFIED SOLUTION
Avatar of gops1
gops1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Munawar Hussain
Munawar Hussain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jazz__man
jazz__man

ASKER

But for a RadioButtonList the Length is always 1 or at least when debugging thats what it always shows. I have 10 Items that are being pulled from the database and are being bound to each button.

So the first thing I have to do is count number of buttons on the RadioButtonList.
if you are talking about counting in Javascript then the "RadioButtonList" dont hold any collection of its items .. you need to get all input type controls and then checking one by one if it is input then is checkbox, if yes then does it contains id of the RadioButtonList if yes then it is an item of the RadioButtonList
..
if you are talking about length in code serverside then you need to check
MyRadioButtonList.Items.Count  must give you the total intems in the list?
thanks