Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi iam using clear function

VB
Public Sub ClearTextBox(ByVal root As Control)
        For Each ctrl As Control In root.Controls
            ClearTextBox(ctrl)
            If TypeOf ctrl Is TextBox Then
                CType(ctrl, TextBox).Text = String.Empty
              
            End If
        Next ctrl
    End Sub

HTML
 <asp:TextBox ID="txtPODate" runat="server" Width="130px" Height="22px" >
 <img alt="Calendar" src="Styles/Images/calendar1.gif" id="imgAddDate" önclick="javascript:show('<%= txtPODate.ClientID %>')" />
<asp:CompareValidator ID="CVDate" runat="server" ControlToValidate="txtPODate" Display="Dynamic" ErrorMessage=" Please Enter Date Format" YYYY/MM/DD" Operator="DataTypeCheck" Type="Date" ValueToCompare="yyyy/mm/dd">


how to clear the validation. how write the valaidation code......
Posted
Updated 31-Jul-13 21:52pm
v3
Comments
Ankur\m/ 1-Aug-13 6:41am    
As soon as you enter a valid value, the error will go. Not sure what's the problem?
akhil.krish 13-Aug-13 2:33am    
my problem if enter wrong details then go page refresh every time.. so i add the clear button code..but error validation not clear the error msg....?
Ankur\m/ 13-Aug-13 3:34am    
The page won't post if the validation is not successful. If your page is posting, it means your validation is successful so you need to check the validation logic.

1 solution

I think we just need to enter the inputs to clean everything

$("#your_div").click(function() {
$(".error").html('');
$(".error").removeClass("error");
});
 
Share this answer
 
Comments
Ankur\m/ 1-Aug-13 6:42am    
Where is a div in his code and where is the 'error' class?
But yes, correct input will clear the error.
jankichavda 1-Aug-13 6:47am    
@Ankur\m/ i just give idea to display proper way.
akhil.krish 13-Aug-13 2:34am    
where to write this code?

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