aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

how to change the error message of custom validator dynamically using

Aug 22, 2010

Here I will explain how to change the error message of custom validator dynamically using


I have one textbox, one button and one custom validator to validate the textbox whenever user clicks on button.
In customvalidator I have taken ClientValidationFunction="ClientValidationFunction" this clientside function is used to send error message dynamically by using sender object. This sender object will display ErrorMessage dynamically.


<html xmlns="" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function ClientValidationFunction(sender, e) {
var errorMessage = "'" + e.Value + "' is not a good value.";
sender.innerText = errorMessage;
sender.errormessage = errorMessage;
e.IsValid = false;
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"  />
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ClientValidationFunction" ControlToValidate="TextBox1"

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...


Anonymous said...
This comment has been removed by a blog administrator.

Give your Valuable Comments

Other Related Posts

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.