1

I have the same scenario as this question, but with a different problem:

ASP.Net MVC Ajax form with jQuery validation

I've set the AjaxOptions.OnBegin property to call return $('form').validate().form(); which works fine for when validation fails; the validation messages are displayed and the form is not posted. However, since setting AjaxOptions.OnBegin, I now get a full page refresh rather than an Ajax call when there are no validation errors. It only happens if AjaxOptions.OnBegin is set. Any ideas?

2 Answers 2

2

I've fixed my problem. I was setting the value of OnBegin to return $("#form").validate().form() which was never going to work because it's expecting a function name, so I created a function:

function validateForm(){
   return $("#form").validate().form();
}

and set the OnBegin property to validateForm.

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

Comments

0

Maybe when AjaxOptions.OnBegin returns true, it exits the Ajax call.

Try setting AjaxOptions.OnBegin to something like

if(!$('form').validate().form()) {
  return false;
}

Only return false. If its valid, it just continues.

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.