Validating a single radio button is not working in available javascript validation script

Posted by OM The Eternity on Stack Overflow See other posts from Stack Overflow or by OM The Eternity
Published on 2011-01-01T12:29:49Z Indexed on 2011/01/01 12:53 UTC
Read the original article Hit count: 295

Hi All,

I have randomly generated radio button series like

<input type="radio" name="creatorusers" value="1">
<input type="radio" name="creatorusers" value="1">
<input type="radio" name="creatorusers" value="1">
<input type="radio" name="creatorusers" value="1">
.....so on

But I get only ONE radio button and execute the javascript validation given for it to chk whether the radio button is selected or not, then it doesnt work Ples help me out in resolving this.

mycreator = -1;

  for (i=frm.creatorusers.length-1; i > -1; i--) {
  if (frm.creatorusers[i].checked) {
  mycreator = i; i = -1;
  }
  }
  if (mycreator == -1) {
  alert("You must select a Creator User!");
  return false;
  }

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about validation