Check whether the one of the radio group buttons is selected - Node.js HTML

Node.js examples for HTML:Radio Button

Description

Check whether the one of the radio group buttons is selected

Demo Code

//check whether the one of the radio group buttons is selected
function isRadioSelected(service_form_id, element_name){
    var radio_choice = false;
  var form = document.getElementById(service_form_id);
    for (var i = 0; i < form.elements.length; i++) {
        var element = form.elements[i];
        if (element.type == 'radio' && element.name == element_name) {
            if (element.checked) 
                radio_choice = true;/*from   w w w  .ja v  a 2 s  .  c o  m*/
        }
    }
    if (!radio_choice) {
        return false;
    }
    return true;
}

Related Tutorials