Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Highlighting a CMS field with yellow color for ValidationErrorSeverity.Warning. Currently, only for Error it highlights the field with red color.


I wanted to have the below features along with field validation. I couldn’t find any article on this. Please help us on this. 

1.      Highlighting a CMS field with yellow colour if it fails warning validation (ValidationErrorSeverity.Warning). Currently, only for Error it highlights the field with red colour.

2.      Is there any option to have the notification box open by default when there is a validation message? Now the user has to click the icon to see the messages.

Nov 28, 2019 17:07

Hi Ravindra,

Thanks for replying to my post. I have already implemented IValidate interface for showing warning message and it works fine. Now, I am looking for highlighting the field in editor when it fails the validation. The field will get auto highlighted in Red color for Severity Error, but for warning this is no happening. I am trying to achieve this.

Nov 29, 2019 10:48

Ah ok.

I have not implemented this but I found something interesting if it works for you.

Like instead of highlighting field you can display a custom message or give the field name to the content author.

public virtual string Title{ get; set; }
public class CustomValidationAttribute : ValidationAttribute
    protected override ValidationResult IsValid(object value, ValidationContext     validationContext)
         if (value.ToString().Contains("bad"))
            return new ValidationResult ("This is contains bad word");
          return ValidationResult.Success;
Nov 29, 2019 14:07

And could you please post the code sample here so that we can review it.

Nov 29, 2019 14:46

Hi Ravindra,

As mentioned earlier, I am able to validate and show warning message with field name in alert box for the editors. As an additional feature, I am looking to highlight the corresponding field also with a color as it does with for ex: Required field validation error.

Edited, Nov 29, 2019 14:56

Hi Anish, I'm afraid that the client side validation in CMS UI is limited to errors in this regard and I would advise against trying to hack around it. There are a number of things involved in validation so I suspect it would be complicated to get it right.

Dec 02, 2019 13:31
Anish - Dec 09, 2019 15:22
Thanks Nicklas
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.