views:

290

answers:

2

Alright this problem has been driving me a little crazy.

I have a checkbox on my form that looks like this:

<%=Html.CheckBox("Agreement", false)%>Yes, I agree to the terms

And then I have a js file that is loaded into the browser after jquery and jquery.validate are loaded that looks like this:

$.validator.setDefaults({
submitHandler: function() { alert("submitted!"); }
    });

    $().ready(function() {

        // validate signup form on keyup and submit
        $("#campForm").validate({
            rules: {
                Agreement: "required"
            },
            messages: {
                Agreement: "Please accept our policy"
            }
        });


    });

So reading the documentation this should work but it never does. What am I doing wrong?

+1  A: 

Are you returning validate on the form submit? Just a guess...

Shawn Simon
Form submit looks like this <form id="campForm" action="<%= Url.Action("ProcessPayment", "Registration") %>">
Al Katawazi
Technically it shouldn't get that far right? The validation intercepts the submission of the form and runs its routine.
Al Katawazi
+2  A: 

I thought the syntax was supposed to be:

rules: {
    Agreement: {required: true}
}

I could be wrong though. This is just off the top of my head.

Kevin Pang
tried it your way, no joy.
Al Katawazi