Hello! I have part in my web app that the user will see this 8 check boxes, and he is only allowed to check 3 check boxes, my problem is that How do I check if the user check the correct textbox?

You shall want to use JavaScript to do this on the client side and then use a server side to verify it when the user submits the form.

here's what I did, but It's not working, can you take a look at this please? thanks :)

my script:

function checkAnswer()
          {
            if( !document.myForm.sub.disabled )
          {
              window.clearTimeout( timeout );

              if( document.myForm.spell1.checked == true) && ( document.myForm.spell2.checked == true) && ( document.myForm.spell3.checked == true) && ( document.myForm.spell4.checked == false) && ( document.myForm.spell5.checked == false) && ( document.myForm.spell6.checked == false) && ( document.myForm.spell7.checked == false) && ( document.myForm.spell8.checked == false)
              {
                count++;
                 alert("CONGRATULATIONS! YOU GOT THE RIGHT COMBINATION!!");
                  location.href = 'place1.html';

              }
              else
              {
                 count++;
                 if (count < 3){
                 alert( "WRONG COMBINATION! Attempt: " + count );
                 }
                 else{
                 alert("Sorry. Please remember your pin! Attempt: " + count + " times!");
                  location.href = 'place2.html';
                 }

              }
          }
       }

and my form is:

<form name="myForm" method="post" onsubmit="JavaScript: checkAnswer();return false;" autocomplete="off">

    <center> <b> <h3> <font color="white" face="comic sans"> Choose </font> </b> </center>    </h3>
    <font size="6px" color="white" face="CURSIVE"> <b>
    <input type="checkbox" id="spell1" name="spell1" >spell1<br>
    <input type="checkbox" id="spell2" name="spell2" >spell2 <br>
    <input type="checkbox" id="spell3" name="spell3" >spell3<br>
    <input type="checkbox" id="spell4" name="spell4" >spell4 <br>
    <input type="checkbox" id="spell5" name="spell5" >spell5<br>
    <input type="checkbox" id="spell6" name="spell6" >spell6<br>
    <input type="checkbox" id="spell7" name="spell7" >spell7<br>
    <input type="checkbox" id="spell8" name="spell8" >spell8 <br>
    </b></font>

    <b> <center> <input type="submit" value="Submit" name="sub" style="height: 40px; width: 70px" /> </center> <b>

    </form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.