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.
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;
}
}
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.
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.
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.