Try our conversational search powered by Generative AI!

PageType Before and End date validation



I am looking at adding validation to a Start Date and End Date - where the user can not enter an End Date before the Start Date. The code is in the pageType and will be used in the CMS for a page set up.

Is there any way that this can be done?



Feb 25, 2014 9:25

Have you tried to write your own validation class that implements IValidate interface?

Feb 25, 2014 11:57

You could also use an InitializableModule to hook into the saving event:

// inside Initialize 
ServiceLocator.Current.GetInstance<IContentEvents>().SavingContent += DisplayModesInitialization_SavingContent;

void DisplayModesInitialization_SavingContent(object sender, ContentEventArgs e)
       if (DatesNotValid(e.Content))
              e.CancelAction = true;
              e.CancelReason = "Your error message";



Feb 25, 2014 12:39

This does not seem to work in neither 7.12.1 nor 7.14.1 (I tried upgrading since it did not work in 7.12.1).

I receive the following:

After which the whole UI gets slow and hardly works. Bug?

Edited, Oct 10, 2014 9:03

Image upload does not seem to work either. :)
Here's a link:

Edited, Oct 10, 2014 9:04

I wrote a blog post a while back about using the IValidator interface that may be of use:

Oct 10, 2014 11:13

Thank you David! It's really a clean approach! :)

Oct 10, 2014 11:30
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.