Copied to clipboard

Flag this post as spam?

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


  • David Fenton 3 posts 73 karma points
    Feb 18, 2019 @ 10:41
    David Fenton
    0

    Unobtrusive validation is adding validation error message even when turned off

    I'm using a custom field type and I'm returning a validation error from it on purpose - for development. I'm trying to style the validation. In order to style the page as required I need to intercept the validation calls so that instead of a span being inserted I get other elements in my form changed. I did a proof of concept of this in a stand alone MVC app and it worked beautifully.

    When I put the js code into my Umbraco site the hooks get inserted BUT the code never fires. I thought it was just an issue with the unobtrusive library being loaded in the wrong order. However this appears not to be the case.

    What I get appearing in the DOM is 2 span class="field-validation-error" elements.

    What is more bizarre is, whilst trying to debug this:

    • I turned off validation with @Html.EnableClientValidation(false); @Html.EnableUnobtrusiveJavaScript(false);
    • I removed elements with: data-val="true" data-val-required="" from my page
    • I've even stripped jQuery.validate and jQuery.validation.unobtrusive libraries out of my Umbraco and according to F12 tools they're not loaded.

    BUT I'm still getting the span class="field-validation-error elements!

    I'm at a loss. I've burnt days on this issue but no luck! I've not got a clue what to do next.

    Any help or ideas gratefully accepted

  • David Fenton 3 posts 73 karma points
    Feb 18, 2019 @ 13:14
    David Fenton
    0

    I've made some progress myself. It appears I only get the issue when it's a custom control that is doing custom validation, i.e. public override ValidateField() is returning something other than an empty list.

    This leads me to think that it is Umbraco adding these validation spans.

    Anyone got any ideas how to either stop this behaviour or at least be able to tap into it so that I can manipulate the DOM elements to my requirements?

Please Sign in or register to post replies

Write your reply to:

Draft