Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

ASP.NET 2.0 Quickstart Tutorials

CustomValidator

The CustomValidator control calls a user-defined function to perform validations that the standard validators can't handle. The custom function can execute on the server or in client-side script, such as JScript or VBScript. For client-side custom validation, the name of the custom function must be identified in the ClientValidationFunction property. The custom function must have the form function myvalidator(source, arguments) Note that source is the client-side CustomValidator object, and arguments is an object with two properties, Value and IsValid. The Value property is the value to be validated and the IsValid property is a Boolean used to set the return result of the validation. You can view a client-side validation example in the Validating Form Input Controls section.

For server-side custom validation, place your custom validation in the validator's OnServerValidate delegate.

The following sample illustrates using the CustomValidator control.

VB CustomValidator1.aspx
Run Sample View Source

For a detailed discussion of Web Forms validation, please see the Validating Form Input Controls section of this QuickStart tutorial.