Skip to main content

ASP.Net CustomValidator Control

CustomValidator: The CustomValidator control allows writing application specific custom validation method for both the client side and the server side validation.

·         The client side validation is accomplished through the ClientValidationFunction property. The client side validation method should be written in a scripting language, like JavaScript, jQuery etc., which the browser can understand.
·         The server side validation method must be called from the controls OnServerValidate event handler. The server side validation routine should be written in any .Net language, like C# or VB.Net.

CustomValidator additional properties (Check here for other default properties and sample):

Property
Description
ClientValidationFunction
Specifies the name of the client-side validation script function to be executed. 
Note: The script must be in a language that the browser supports, i.e. JavaScript, jQuery.

Example of client side function:
Function FunctionName (source, arguments)
OnServerValidate
Specifies the name of the server-side validation script function to be executed

  Custom Validation Control:

<asp:CustomValidator ID="cvTest" runat="server"
       ClientValidationFunction="ValidateMethodName"
       ErrorMessage="*Required">
</asp:CustomValidator>

Comments