I found myself with a bit of a challenge yesterday. I have a form which has client validation but also has a message displayed back from the server after a save.

When a save happens a "Update successful" message is displayed on the screen as an <asp:label>.

When the client side validation happens, then one of many error messages are displayed on the screen.

This means that both the "Update successful" and the error messages are displayed on the screen at the same time. This obviously isn't ideal and doesn't give the user a clear message.

For a while I was going to do this using a <asp:customvalidator> calling some javascript to clear out the label. And then I read "The custom validation subroutine is not called when the control being validated does not contain any data. The only control that you can use to check for an empty form field is the RequiredFieldValdiator control" which scuppered those plans.

I then did a bit of googling and discovered that I could use the Attributes property to get at the client side events of an element. So, a bit of code that does
TextBox1.Attributes["onblur"] = "for(i=0; i<document.all.length; i++){if (document.all[i].id.indexOf('Label1') > -1) { var element = document.all[i];element.innerHTML='Changes have been made';};}";
works like a charm and when focus leaves TextBox1, the text in the element Label1 changes to be "Hello".

I then manipulated it a bit more and discovered that if in the html the Label1 element is set to visible="false", then the javascript fails due to the non-existance of that element.

So, the final result is:

The basic form:

When a required field is missing (note both the validator text and the change of text in the label caused by changing the focus):

When the two textboxes don't have identical content:

With asp code of:

<asp:Label ID="Label1" runat="server" Text="Label">Please make some changes</asp:Label>
<br />
<asp:TextBox ID="TextBox1" runat="server">TextBox1</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1" Text="RequiredFieldValidator"></asp:RequiredFieldValidator>
<br />
<asp:TextBox ID="TextBox2" runat="server">TextBox2</asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator" ControlToCompare="TextBox2" ControlToValidate="TextBox1">CompareValidator</asp:CompareValidator><br/>
<asp:Button ID="Button1" runat="server" Text="Button" />

and a code behind of

protected void Page_Load(object sender, EventArgs e)
  if (Label1.Visible)
   TextBox1.Attributes["onblur"] = "for(i=0; i -1) { var element = document.all[i];element.innerHTML='Changes have been made';};}";