Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox Validation

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm trying to validate a series of checkboxes.

If the user gets the combination of boxes correct (Keegan - Liverpool - Argentina), they progress to the next page. If not, they get an error message and the checked boxes all empty.

I've downloaded the 'Check Form MX' extension from yaromat.com but cannot seem to validate more than one checkbox per form.

I'm really struggling and in need of help!

Any feedback would be greatly appreciated
Brett

 
not sure about the validation but you might want to consider using 3 sets of 3 radio buttons rather than 9 checkboxes. At the moment, the users can select multiple answers for the same question.

Tony
 
How about this...
Code:
<html>
<head>
<script language=javascript>
  function chkMe() {
    if (document.myform.wc_keegan.checked && document.myform.wc_liverpool.checked && document.myform.wc_argentina.checked) {
      return true;
    }
    else {
      var j = 0;
      var howmany = document.myform.elements.length;
      for (var i = 1; i < howmany; i++) {
        if (document.myform.elements[i].type == 'checkbox')
          j = j + 1;
          var fld = eval(&quot;document.myform.&quot; + document.myform.elements[i].name);
          fld.checked = false;
      }
      return false;
    }
  }
</script>
</head>
<form name=myform onsubmit=&quot;return chkMe()&quot;>
<input type=checkbox name=wc_keegan>Keegan<br>
<input type=checkbox name=wc_paris>Paris<br>
<input type=checkbox name=wc_liverpool>Liverpool<br>
<input type=checkbox name=wc_spain>Spain<br>
<input type=checkbox name=wc_argentina>Argentina<br>
<input type=submit name=wb_submit>
</form>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top