Creating custom validation controls

Jack Neary asked on March 15, 2017 10:57


I would like to create a custom validation control.

Similar to the <cms:CMSRegularExpressionValidator /> and <CMSRequiredFieldValidator/> controls.

I can see they're all based on System.Web.UI.WebControls.BaseValidator here: but how can I create them as controls that are usable like the standard Kentico ones?

<cms:CMSRegularExpressionValidator ID="revFcaNumber" runat="server" ControlToValidate="txtFcaNumber" Display="Dynamic" EnableViewState="false" ValidationExpression="^([0-9]{8}|[a-zA-Z0-9]{10})$" ErrorMessage="Should be either 8 numeric charcters or 10 alpha numeric characters"/>

We use a third party phone number validation service, so I've created a class extending System.Web.UI.WebControls.BaseValidator and implemented the required interfaces, now it's just how I use this class with my form, which is an extended clone of the stock registration form. (Custom registration logic required)

Any links, tutorials or advice would be greatly appreciated.

Thanks, Jack

   Please, sign in to be able to submit a new answer.