0

I'm just overlooking something simple... but my form, which is an Ajax form, always submits even if the validation fails. I'm not using jQuery validation, just the standard .NET MVC validation.

Each of the field failing get show the validation message and highlight the field, but the form just submits anyway.

Is there an OnBegin script I can call to prevent the form from submitting if there are errors?

Thanks for the help!

Ajax.BeginForm("EditUserProfile", new AjaxOptions { HttpMethod = "Post", OnComplete = ToggleViews", UpdateTargetId ="userProfileContainer" })

1 Answer 1

0

Did you enable client validation and included the proper client scripts MicrosoftAjax.js, MicrosoftMvcAjax.js and MicrosoftMvcValidation.js to your page?

<% Html.EnableClientValidation(); %>
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, that's all working. As I mentioned, the client side scripts to cause validation to happen. The invalid fields show the validation messages and the CSS is applied to the invalid input fields. But the form posts anyway.

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.