[RESOLVED]unobtrusive client side validation not working when using ajax.beginform?


Why does unobtrusive client side validation not working when using ajax.beginform? I am using MVC 3 and have the following jquery libraires declared yet when submitting an Ajax.BeginForm the unobtrusive validation doesnt work.

@section scripts {
    @Content.Script("jquery.validate.min.js", Url)
    @Content.Script("jquery.validate.unobtrusive.min.js", Url)
    @Content.Script("jquery.unobtrusive-ajax.min.js", Url)

  @using (Ajax.BeginForm("AddComment", "Blog", new AjaxOptions
            HttpMethod = "POST",
            InsertionMode = InsertionMode.Replace,
            UpdateTargetId = "blogComments",
            LoadingElementId = "progress"


        @Html.HiddenFor(model => model.Blog.BlogID)

                Add Comment 
                @Html.TextAreaFor(model => model.BlogComment.Comment, 1, 100, new { id = "commentbox" })
                @Html.ValidationMessageFor(model => model.BlogComment.Comment)
        <div >
              <input type="submit" id="button" value="Add" />

In my web config I also have the following enabled:

    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />

Isa this a partial view rendered in other main view?

if so, how r u rendering?

either through @Html.Partial() or loading on on click of something?

One of the things about validation is that you have a choice in how things are displayed:


excludePropertyErrorsType: System.Boolean
true to have the summary display model-level errors only, or false to have the summary display all errors.

Try false and let us know what happens.

the Ajax.beginform declaration is in a main view and the form fields are in partial view called using  @Html.Partial("_CreateComment", Model)

Hi GStar99,

Thanks for your post.


unobtrusive client side validation not working when using ajax.beginform?

what’s error it renders?You can add script tags in LayOut.cshtml instead of index.cshtml page


More information:

#Unobtrusive AJAX Form Validation in ASP.NET MVC


If there’s anything else I can do for you regarding this matter,please feel free to post this forum.

Best Regards,



I’ve moved the script to Layout.cshtml and it still doesnt work?



what’s error?Did you add all scripts to layout.cshtml?

Leave a Reply