0

I am having trouble with my form validation. I have a form class with the Required attribute on it and I have ClientValidationEnabled to true in my web.config. I also have this call on my page @{Html.EnableClientValidation();}

I am using ajax form with the before submit option to catch the validation. Here is what I have:

$(document).ready(function () {
    var options = {
        beforeSubmit: ensureValid
    };
    $('#applyForm').ajaxForm(options);
});

function ensureValid(formData, jqForm, options) {
    var result = $('#applyForm').validate();
    console.log(result.valid());
    return result.valid();
}

The code hits the ensureValid function but keeps continuing to the action in the controller even when I know a property should fire.

Thank you for any insight,

Brenna

1
  • $(document).ready(function () { can be shortened to $(function() ) { Commented Mar 15, 2011 at 20:15

1 Answer 1

1

If you are using asp.net-mvc-3, I would recommend at looking at using jquery.validate to perform your validation. It's far easier to setup, and generates cleaner code. You can see how to set this up in my blog post (I also cover a possible problem you could run into).

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

Comments

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.