javascript to validate .net radiobutton list

  • Thread starter Thread starter Linda
  • Start date Start date
L

Linda

I have a radiobutton list and I need to use javascript to test the
values.
If value is 'A' or 'B' or 'C' then alert the user with message and
uncheck a checkbox. My problem is getting the values of the radiobutton
list in javascript.

Anyone have ideas or snippets to look at?
 
This is one way of doing it:

function validateRbl()
{
var rb = document.forms[0].rbl; // rbl is the RadioButtonList control ID
for (var i=0; i< rb.length; i++)
{
if (rb.checked && (rb.value == 'A') || (rb.value == 'B') ||
(rb.value == 'C'))
{
alert ("Uncheck a item...");
return;
}
}
alert ("All perfect.");
}

Hope this hels.
 
I tried this snippet but am getting "undefined" instead of a value for
the rbl (RadioButton List).
 
rbl is an example. You should really use the ID of the RadioButtonList you
have defined in your code.

Sorry if this is too late.

I tried this snippet but am getting "undefined" instead of a value for
the rbl (RadioButton List).
 
Back
Top