Copied to clipboard

Flag this post as spam?

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


  • mizzle 90 posts 325 karma points
    Jul 20, 2022 @ 16:36
    mizzle
    0

    Validation/Error messages not displaying for basic MVC forms

    Submitting a form with required fields empty fails to submit, but also fails to display errors.

    Form's model has pretty standard setup for each field, example:

    [Required (ErrorMessage = "A first name is required.")]
    [Display(Name = "First Name")]
    public string FirstName { get; set; }
    

    The errors are supposed to display within a div above the form:

    <div class="errors">
              @Html.ValidationSummary()
      </div>
    

    I can't figure out what's wrong. The site is Umbraco version 8.17.0 and I have an 8.11.0 site with the exact same form setup that displays errors properly. Is there something in the later Umbraco 8 versions that might be causing a problem?

  • Damian 61 posts 342 karma points
    Jul 20, 2022 @ 17:24
    Damian
    0

    I'd check to verify that you have the associated/required scripts loading: in 8.6.0+ it's as simple as the following @Html.RenderUmbracoFormDependencies()

    This will then output the aspnet-validation js which is likely the missing piece.

    More info from the Umbraco docs: https://our.umbraco.com/Documentation/Add-ons/UmbracoForms/Developer/Prepping-Frontend/index-v7#umbraco-forms-version-860

    hope this helps!

  • mizzle 90 posts 325 karma points
    Jul 20, 2022 @ 17:57
    mizzle
    100

    Hi, thanks for your response. But this isn't an Umbraco Forms form, just a standard/simple MVC form. It's just that the only difference between this form on my 8.17.0 site and the working form on my 8.11.0 site is the Umbraco version, so I was wondering if there were settings changed between versions that could be disrupting the verification.

    Could the associated scripts still be the problem? And if so, how do I check this without needing the Umbraco Forms code?

    EDIT: It was indeed a script issue, even for a non-Umbraco Forms setup.

Please Sign in or register to post replies

Write your reply to:

Draft