Validate radiobuttonlist in javascript
Here is
the function for validating radiobutton list to
select at least on Item through JavaScript radio button list is a ollection of rediobuttons so we have to navigate all sub radio button and check that if selected or not.
just copy and paste the code given bellow and pass the the parameter that is id of radio button.
just copy and paste the code given bellow and pass the the parameter that is id of radio button.
function
validateRadioButtonList(rblId) {
var
listItemArray = document.getElementsByName(rblId);
var
isItemChecked = false;
for (var i = 0; i < listItemArray.rows.length; i++) {
var
listItem = document.getElementById(rblId + "_"
+ i);
if
(listItem.checked) {
isItemChecked = true;
}
}
if
(isItemChecked == false) {
alert("Please
select atleast one item");
return false;
}
}