Using a custom validator lets you insert your client-side validation method into the asp.net client-side validation "pipeline" so that your custom validation works just like the out-of-the-box asp.net validation.
Doing client-side validation with the custom validator will not call any server-side (c#) methods, it will instead execute javascript that you will write. Here's how you do it.
First, write your client-side javascript, following the same pattern as below:
<script language="JavaScript">
<!--
function ValidateSomething(sender, args)
{
var mySomething = args.Value;
if (mySomething != validSomething)
{
args.IsValid = false;
return;
}
args.IsValid = true;
}
// -->
</script>
Either register that script with the Page.ClientScriptManager object, or just simply embed it in your .aspx markup. Then, you have to set the ClientValidationFunction property of your CustomValidator in your code-behind. Like this:
myCustomValidator.ClientValidationFunction = "ValidateSomething";
myCustomValidator.EnableClientScript = true;
That's it! Now when your page fires the client-side validation, your custom validation function should be called just like the other O-O-B validators.
Hope this helps!
Matt