0

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?

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

2 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.