I know I have to be doing something dumb here. Just need a second set of eyes.
Validating if my radio box has been checked:
<input type="radio" name="cont_amt" id="cont_amt" value="1000">
//alert(theForm.cont_amt.value);
var con_optLength = theForm.cont_amt.length;
var chkd="";
for(var i = 0; i < con_optLength; i++) {
if(theForm.cont_amt[i].checked) {
chkd=theForm.cont_amt[i].value;
}
}
if ( chkd == "" ) {
reason += "\t" + "Must select a contribution option" + "\n";
}
I’m always hitting my alert because my length is always undefined.
You should work with
document.getElementsByName.And here is a nice jsFiddle Demo to see that I’m not lying.
Note: I suspect you do this because you have several radio buttons like this. If this is the case, you should remove the ID attribute because it must be unique in the document.