Copied to clipboard

Flag this post as spam?

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


  • Marco Vezzani 20 posts 174 karma points
    Jun 24, 2021 @ 11:41
    Marco Vezzani
    0

    Styling user error's in Forms

    So this is the first time I have used forms and am currently playing about with it to get used to how it all works. I have created a theme based off the bootstrap one curently in there as we use bootstrap with a few of our own css classes as well.

    In the bootstrap form where there is the error bit forthe element

    @if (Model.ShowFieldValidaton)
    {
         @Html.ValidationMessage(f.Id)
    }
    

    What I am wondering is, is there a way to add a class to the outputted validation error?

    perhaps like you do with these?

    @Html.SetFormFieldClass("form-control")
     @Html.SetFormFieldWrapperClass("form-group")
    
  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Jun 24, 2021 @ 15:29
    Marc Love (uSkinned.net)
    0

    Hi Marco,

    Why not just add a div within your validation check with your custom class style.

    @if (Model.ShowFieldValidaton)
    {
        <div class="myValidationStyle">
         @Html.ValidationMessage(f.Id)
        </div>
    }
    

    Cheers,

    Marc

  • Marco Vezzani 20 posts 174 karma points
    Jun 25, 2021 @ 08:03
    Marco Vezzani
    0

    Hi Marc

    Thats what I had already done but I though there could be a better way of doing it, as Umbraco Forms generates a spanalready around the errr text with a class of (field-validation-error) on it. So I thouht there might be a way to also add your own class as well

Please Sign in or register to post replies

Write your reply to:

Draft