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

Vote:
 

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.

#210592
Nov 28, 2019 17:07
Vote:
 

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.

#210599
Nov 29, 2019 10:48
Vote:
 

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.

[CustomValidation]
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;
     }
}
#210605
Nov 29, 2019 14:07
Vote:
 

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

#210610
Nov 29, 2019 14:46
Vote:
 

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.

#210612
Edited, Nov 29, 2019 14:56
Vote:
 

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.

#210647
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.