Tyler Brinks
Tyler Brinks

Reputation: 1201

ASP.NET Ajax.BeginForm Posts Even If Validation Fails

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" })

Upvotes: 0

Views: 678

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038800

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

<% Html.EnableClientValidation(); %>

Upvotes: 0

Related Questions