Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void txtEmailCC_Validating(object sender, CancelEventArgs e)
        {
           //in my form their is a field of cc(where we can add multiple email address),so how can we validate this field.if user will enter wrong email address then show -enter correct email address(it should validate email addresses like-01@gmail.com,name0@gmail.com..means as CC field present in our gmail by which we can send email to many people).
            
        }
Posted
Updated 7-Sep-12 1:45am
v2
Comments
Vani Kulkarni 7-Sep-12 7:38am    
PLease elaborate. Your question is unclear.
StackQ 7-Sep-12 7:43am    
in my form their is a field of cc(where we can add multiple email address),so how can we validate this field.if user will enter wrong email address then show -enter correct email address(it should validate email addresses like-01@gmail.com,name0@gmail.com..means as CC field present in our gmail by which we can send email to many people).
[no name] 7-Sep-12 7:47am    
use a regular expression to validate the email
StackQ 7-Sep-12 7:51am    
ya i used it but showing error if i m using 120ram@gmail.com(means if i m starting my email id with numeric then showing error,but it's not right,in practical email id exists,who starts with numeric.)so what will be solution of this problem..any idea?so plz
StackQ 7-Sep-12 7:52am    
and one problem exist-that is i can't use multiple email address

1 solution

use regex function like below
C#
string[] aryMailId = txtcc.text.split(",");
for (i=0;i<arraylist.length;i++)>
{
    string Inputstr=aryMailId[i];
    Match rex = Regex.Match(Strings.Trim(InputStr),"^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,3})$", RegexOptions.IgnoreCase);
    if (rex.Success == false)
    {
        //message ERROR
    }
}

Happy Coding!
:)
 
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