MVC 4 client side validation not working

后端 未结 21 1336
情话喂你
情话喂你 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:50

    My problem was in web.config: UnobtrusiveJavaScriptEnabled was turned off

    <appSettings>

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

    <add key="UnobtrusiveJavaScriptEnabled" value="false" />

    </appSettings>

    I changed to and now works:

    `<add key="UnobtrusiveJavaScriptEnabled" value="true" />`
    
    0 讨论(0)
  • 2020-12-02 14:51

    Be sure to add this command at the end of every view where you want the validations to be active.

    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
    }
    
    0 讨论(0)
  • 2020-12-02 14:54
      @section Scripts
     {
    <script src="../Scripts/jquery.validate-vsdoc.js"></script>
    <script src="../Scripts/jquery.validate.js"></script>
    <script src="../Scripts/jquery.validate.min.js"></script>
    <script src="../Scripts/jquery.validate.unobtrusive.js"></script>
    <script src="../Scripts/jquery.validate.unobtrusive.min.js"></script>
    }
    
    0 讨论(0)
提交回复
热议问题