Click here to Skip to main content
15,896,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used the custom validator for date. It gives me the ErrorMessage whenever I select any wrong date, but this error message does not clear out on Click event of clear button. Is it how the custom validator behaves or is there something that I can change in my code for this to happen..
can somebody please tell me?

How to write the code to clear the ErrorMessage of Validator on click event of button using javascript??

Thanks in advance.
Posted

1 solution

If you don't require to validate for clear button click then set CausesValidation="false" for clear button.

check Enable or Disable ASP.Net validation on client side[^]
 
Share this answer
 
v2
Comments
diptichalke2010 2-Feb-11 9:07am    
I want to clear both textbox value and Error message on button click event as per your answer It will just clear the error message. I can do either operation i.e.either clear textbox value or error message. It you have any other answer please let me know . Thanks in advance.
m@dhu 3-Feb-11 1:23am    
This will clear textbox and disable validation.
<asp:Button ID="btntest" runat="server" CausesValidation="false" OnClientClick="document.getElementById('TextBox1').value=''"/>
diptichalke2010 3-Feb-11 1:28am    
Thank you for your assistance.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900