Hi,

I'm trying to validate a checkbox before going to checkout in a shop
(without using the validate plugin), but the JQuery doesn't seem to be
working at all (i.e. nothing happens). Tried debugging in Firebug, but
I can't seem to pinpoint the problem.

Can someone have a look and see what I'm doing wrong please?

Thanks,

osu

HTML:

<form action="/cart" method="post" id="cartform">
<input type="submit" id="update-cart" name="update" value="Update
basket" class="checkout-btns" />
<input type="submit" value="Checkout" name="checkout" class="checkout-
btns" />
<a href="/" class="checkout-btns" />Continue shopping</a>
<p id="tandc">
<input type="checkbox" name="attributes[accept-t-and-c]" id="accept-t-
and-c" value="yes"  CHECKED />
<label for="accept-t-and-c">Please confirm you have read and
understood our <a href="#">Terms and Conditions</a> (required)</label>
</p>
</form>

JQUERY:

        <script type="text/javascript">
        //<![CDATA[
                // JQuery function to test if t-and-c checkbox checked
                $(document).ready(function(){
                        $("input[checkout]").click(function(){
                                var pass = false;
                                if ($("#accept-t-and-c").attr("checked") !== 
true){
                                        alert("You have to agree to our terms 
and conditions to make a
purchase!");
                                } else
                                // let 'em through to checkout
                                pass = true;
                        });
                });
        //]]>
        </script>

Reply via email to