how to disable form submit and check the form
<p>I have the following code. I need to see how many checkboxes have been checked in my form and if there are 4 or less submit the form and if there are more display an error and don't submit.</p>

<pre><code>function SetHiddenFieldValue() 
{
    var checks = document.getElementById('toppings').getElementsByTagName('input');
    var toppings = new Array();
    var randomNumber = Math.floor((Math.random() * 9000) + 100);
    var totalChecked = 0;
    var itemPrice = 5.99;

    for (i = 0; i &lt; checks.length; i++)
    {
        if (checks[i].checked)
        {
            toppings[i] = checks[i].value;
            totalChecked += 1; 
        }
    }

    if (totalChecked &gt; 4) {
        alert("You can only choose up to Max of 4 Toppings");   
    } else {    
        itemPrice = itemPrice + (totalChecked * 0.99);  
        document.getElementById('my-item-name').value = toppings.join("\t");
        document.getElementById('my-item-id').value = randomNumber;
        document.getElementById('my-item-price').value = itemPrice;
    }
</code></pre>

<p>And my form is:</p>

<pre><code>&lt;form id="pizza" name="pizza" method="post" action="" class="jcart" onsubmit="return SetHiddenFieldValue();"&gt;
    &lt;input type="hidden" name="my-item-id" id="my-item-id" value="" /&gt;
    &lt;input type="hidden" name="my-item-name" id="my-item-name" value="" /&gt;
    &lt;input type="hidden" name="my-item-price" id="my-item-price" value="" /&gt;
    &lt;input type="hidden" name="my-item-qty" value="1" /&gt;
    &lt;input type="submit" name="my-add-button" value=" add " /&gt;
&lt;/form&gt;
</code></pre>

<p>any help would be appreciated.</p>
