---
title: CustomValidator and SetControlError example
slug: customvalidator-and-setcontrolerror-example
docTags: 
createdAt: 2025-06-11T20:26:19.222Z
---

Attached is an example of a task that uses the CustomValidator control and the SetControlError function to perform validation in server side script.  

This may be a good solution when you have some validation to perform that is a little bit too complex for an expression in an ExpressionValidator control.



```xml
<Innovation.Activate siteName="CAMDEV" orgName="CAMDEV V8" SourceSQL="v8servercam" SourceServer="V8SERVERCAM" SourceUser="ACTIVATEDEMO\cameron">
  <Task Name="CustomValidator V8" Description="" Status="A" Version="1">
    <parameter Name="Arguments" Description="Binding arguments for WebForm" Type="Task Arguments" Flags="None" Version="18" Owner="9cea3147-e9ba-49db-a1b3-867ee9beff14" OwnerName="CAMDEV" OwnerPriority="100"><![CDATA[<?xml version="1.0" encoding="utf-16"?><arguments><lp /><thing /><h /><date type="datetime" /><range /><phone type="phone" /><radio /><ListBox1 /><ImageUpload1 /><input /></arguments>]]></parameter>
    <parameter Name="Web.Form" Description="" Type="Web Form" Flags="None" Version="60" Owner="9cea3147-e9ba-49db-a1b3-867ee9beff14"><![CDATA[<?xml version="1.0" encoding="utf-16"?><WebForm><Panel Width="100%" Form.Load="Form_Load" Form.Submit="Form_Submit"><TextBox ID="TextBox1" ActivateBind="input" Label="Text" /><CustomValidator ID="customError"></CustomValidator><HelpPanel ID="HelpPanel1" Title="CustomValidator Example" Description="This example uses a CustomValidator control and Server script to validate the text of the control.  You must enter the text &quot;VALIDATE&quot; to continue" /></Panel><ServerScript><Text><![CDATA[using System;
using Innovation.Activate;
using Activate.Web;
using Activate.Web.Controls;
using Innovation.Activate.Forms.Xaml;

class Script : WebFormScript
{
	public void Form_Load(object sender, EventArgs e)
	{
	}

	public void Form_Submit(ActivateHttpRequest request)
	{
		if (Job.Arguments.GetString("input") != "VALIDATE")
			request.Page.SetControlError("customError", "Text != \"VALIDATE\"");
	}
}
] ]></Text></ServerScript></WebForm>]]></parameter>
    <parameter Name="Web.Wizard" Description="Options for the Web site" Type="Xml" Flags="Required" Version="2" Owner="9cea3147-e9ba-49db-a1b3-867ee9beff14"><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<form>
  <wizard startPage="System/Form" title="#TODO: Menu Item" icon2="images/group.gif">
    <page name="System/Form">
      <form>=//Job/Task/Web.Form</form>
    </page>
    <page name="Common/GenericConfirm">
      <title> Confirm action title</title>
      <description>Confirm description</description>
      <logo>../images/big_group.gif</logo>
      <message><![CDATA[
		Template Web Form<BR>
		
		User %=weblink(=//Job/user)% as been selected.
	] ]></message>
    </page>
  </wizard>
  <view>
  </view>
</form>]]></parameter>
  </Task>
</Innovation.Activate>
```

