Al Katawazi
Al Katawazi

Reputation: 7242

Jquery.Validate and MVC Framework

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?

Upvotes: 0

Views: 428

Answers (2)

Kevin Pang
Kevin Pang

Reputation: 41442

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.

Upvotes: 2

Shawn
Shawn

Reputation: 19793

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

Upvotes: 1

Related Questions