[Solved] JavaScript alert mechanism not working


Problem is in your for loop condition.It is iterating till length+1 element.Just remove = condition and it will work.

    function validateRadios() {
      var c = document.getElementsByName("qualification");
      for(var a=0;a<c.length;a++) {
        if(c[a].checked ) {
          alert("Form OK!");
          return true;
        }
      }
      alert("Please select one");
      return false;
    } 
     <form onSubmit="return validateRadios();">
     Select your qualification     
        Intermediate<input type="radio" name="qualification" value="inter" />
        Bachelors<input type="radio" name="qualification" value="Bchlrs"/>
        Masters<input type="radio" name="qualification" value="mstrs"/>
       </br>
       <input type="submit" value="Lock details"/>        
    </form>

1

solved JavaScript alert mechanism not working