Click here to Skip to main content
16,008,075 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how i can validate email id on text changed event in asp.net??
Posted

Try matching with regular expression in required event. Try this:
C#
Regex reg = new Regex("^([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]){1,70}$");
if (!reg.IsMatch(txtEmail.Text))
{
    //Show error message.
}
else
{
   //Success.
}



--Amit
 
Share this answer
 
Comments
Member 9332883 5-Sep-12 5:50am    
thank u..is work.,,,
You can have a method in code behind for validation and call it on text changed event of the textbox or you can have a javascript validator which fires on keyup event or you can set on lost focus event.

Hope this helps

Regards,
Sagar
 
Share this answer
 
Comments
Member 9332883 5-Sep-12 5:23am    
i knw that...but i want code for that..!!

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