Copied to clipboard

Flag this post as spam?

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


  • Mike 62 posts 274 karma points
    Oct 07, 2014 @ 18:29
    Mike
    0

    No validation of comments

    Hi Luke,

    I've installed version 2.0.9 into my Umbraco 7.1.6 site and all is working well except that I don't have any form validation at all on the comments form - if I hit Submit it litterally posts into Umbraco. 

    I was doing some work on the layouts and amending the templates and partials and originally thought I'd broken the validation through something that I'd done, but I've since rolled back to a vanilla install testing along the way and then finally uninstalled the package and reinstalled it and still the validation isn't firing. 

    I installed 2.0.9 into v7.1.6 on a different server originally to test things out and the validation did work so I'm wondering if it may be a server configuration issue on this other server. 

    Have you any ideas why this might be happening or any suggestions on what to check? 

    Many thanks,
    Mike

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Oct 07, 2014 @ 21:55
    Nicholas Westby
    101

    I haven't tried this starter kit myself, but one possibility is that client-side validation isn't configured in the web.config. If the package was built incorrectly, it may rely on client-side validation and fail to validate posted forms on the server side. If it's using the typical way of validating forms in MVC, these would need to be present in the web.config:

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

    You can also check for JavaScript errors in the Chrome developer console. If a JavaScript error causes some click handlers to never be created, any AJAX forms may fallback to simple postback forms, which may also explain some validation issues.

  • Mike 62 posts 274 karma points
    Oct 08, 2014 @ 00:13
    Mike
    0

    Hey Nicholas, 

    I checked the web.config on both sites - the one where the validation works and the one where it doesn't - and those two entries don't exit, however, the UnobtrusiveJavaScriptEnabled made me think as I'd seen that reference within the starter kit code. 

    So I checked the Javascript Console in Chrome (brilliant tip by the way!) and it was trying to locate a .js file in the /scripts/ directory which wasn't on the server:

    jquery.validate.unobtrusive.min.js

    The package hadn't installed this file directly and actually checking the Smart Blog demo site and also my other server (with working validation) there seems to be no immediate reference to this file in the source code, but it does exist within the /script/ directory of the demo site. So I uploaded this file and did some cache-bashing and the validation is now working.

    I also seemed to notice that if i'm logged into the Umbraco back-office the validation seems to be bypassed, even with the above file in place, whereas if I log out and clear the browser cache it does work.

    But the important thing is the validation is working now so thanks for pointing me in the right direction here! Hugely appreciated.

Please Sign in or register to post replies

Write your reply to:

Draft