MVC 4 client side validation not working

后端 未结 21 1347
情话喂你
情话喂你 2020-12-02 14:00

Can anyone tell me why client side validation is not working in my MVC 4 application.

_layout.schtml

@Scripts.Render("~/bundles/jquery")
@R         


        
21条回答
  •  悲&欢浪女
    2020-12-02 14:37

    I had the same problem. It seems that the unobtrusive validation scripts were not loaded (see screenshot at the end). I fixed it by adding at the end of _Layout.cshtml

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

    The end result:

       @Scripts.Render("~/bundles/jquery")
       @Scripts.Render("~/bundles/jqueryval")
       @RenderSection("scripts", required: false)
    

    Except for my pretty standard CRUD views everything is Visual studio project template defaults.

    Loaded scripts after fixing the problem: enter image description here

提交回复
热议问题