Search code examples
jqueryasp.net-mvcpartial-viewsunobtrusive-validation

Client side validation issue on partial view


I am working on client side validation on partial view. I am trying to render jaqueryval bundle on master page but its not working.

@Scripts.Render("~/bundles/jqueryval")

In case same bundle render on partial view it works.

I would like to know how I can achieve the same, any small inputs on the same is also greatly appreciated.

Thanks in advance.


Solution

  • First add @Scripts.Render("~/bundles/jqueryval") in your _Layout.cshtml and after that add

    $(function () {        
            $(document).ajaxComplete(function () {
                $.validator.unobtrusive.parse(document);
            });
        });
    

    for parsing the unobtrusive attributes when we get content via ajax.