views:

128

answers:

1

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

A: 

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

<% Html.EnableClientValidation(); %>
Darin Dimitrov
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.
Acoustic