Click here to Skip to main content
15,917,329 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I need to validate text box using validation controls. When i enter some text and the focus is out it should display a custom validator message stating whether the entered text is valid or not. i have written the code in textchanged event and i have created a custom validator with control to validate as textbox. i am setting the error message and color of the message as per my requirement in textchanged event.
Posted
Comments
Ankur\m/ 3-Dec-10 1:30am    
So what is the question?
MathewPV 3-Dec-10 1:33am    
i want to display the custom validator after performing post back in textbox textchanged event

You said you have created a Custom Validator to validate the TextBox. Why do you need textchanged event then?

You can easily achieve this using JavaScript. Write code to check the values in onblur event of the TextBox. Something like this:
XML
<asp:TextBox ID="TextBox1" runat="server" onblur="return validateData();"></asp:TextBox>


JavaScript
function validateData()
{
    //write validation code here.
}


Hope this helps!
 
Share this answer
 
write your validator code on the Leave event of textbox,and if validation failed keep the focus on that textbox(textbox1.focus();)
 
Share this answer
 

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