Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


Validation of radio buttons with Javascript


've combed a ton of the pages on here, and still am incapable to get my explicit validator to work. Basically, when the submit button is clicked, I want the script to verify a radio is checked, if one is checked to do nothing. If one isn't checked I want it to post an alert message.

roughly my html looks like:







my JS page looks like:

function check() {
    var r = document.getElementsByName("c")
    var c = 0

    for(var i=0; i < r.length; i++){
       if(c[i].checked) {
          c = i; }
    }

    alert("please select radio");
}

asked Jul 21, 2015 in JAVASCRIPT by rajesh
0 votes
46 views



Related Hot Questions



Government Jobs Opening


...