Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • CodeMaster2008 151 posts 184 karma points
    Dec 11, 2012 @ 23:58
    CodeMaster2008
    0

    Enable unobtrusive validation for mvc forms

    The form is rendered using "Html.BeginUmbracoForm()" and the model is anotated with some validation attributes, as per sugestion on this documen: http://our.umbraco.org/documentation/Reference/Mvc/forms

    Now, how can I enable client side validation so MVC can automatically wires up these validation attributes with the front-end? 

  • CodeMaster2008 151 posts 184 karma points
    Dec 14, 2012 @ 00:47
    CodeMaster2008
    3

    After a 24 hours shift and unable to come up with a solution (couldn't get client side validation to work) I endup creating this post.
    However, after some sleep I came back and notice some problem with my code.
    Bottom line is: there is nothing special about enabling the client side validation, just had to do the same as I do in any mvc project. 

    Web.config:

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

    And off course, add the javascript references.

        <script src="/scripts/jquery.validate.min.js" type="text/javascript"></script>
        <script src="/scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>

    I tried to delete this post though but since the "Delete" option is not working, I updated it just for fun :-)

     

  • Dan Diplo 902 posts 2775 karma points
    Jun 06, 2013 @ 22:09
    Dan Diplo
    0

    Very helpful! And you can get all the jQuery files from Microsoft's CDN, too - http://www.asp.net/ajaxlibrary/cdn.ashx

  • Sébastien Richer 193 posts 415 karma points
    Jun 14, 2013 @ 23:30
    S├ębastien Richer
    1

    So as a comment here, be carefull to put in these keys in the website's web.config and not that little web.config inside the views folder. I just spent 2 hours moving those to lines to the proper place :)

  • Khemo 1 post 71 karma points
    Dec 10, 2015 @ 21:47
    Khemo
    0

    Thank you so much, CodeMaster2008! Your post listing the keys and scripts helped me solve my issue!

  • LP 4 posts 74 karma points
    1 week ago
    LP
    0

    Did anybody notice that after this change is done user panel stops working? Nothing can be done, every keystroke make the page reload with page saved message.

Please Sign in or register to post replies

Write your reply to:

Draft
Our.umbraco.org is the community mothership for Umbraco, the open source asp.net cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community. This site is running Umbraco version 7.5.6