Click here to Skip to main content
15,891,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I hav 5 textboxes, for entrying emailId's,
i need to have email validation for each textbox and
i should validate the textbox, in such a way that the mailId which i enter in 1st or any other textbox should not repeat in any other text box.

Ex:

TextBox1 :- abc@aa.com
TextBox2 :- abc@bb.com
TextBox3 :- abc@cc.com
TextBox4 :- abc@dd.com
TextBox5 :- abc@aa.com

Here the Textbox1 & Textbox5 are having the same Id, but it should not.
How do i validate in Asp.net.



Regards,
yuva
Posted

1 solution

Depends on where you are doing it.
If the validation is server side:
C#
List<string> list = new List<string>();
public void RunSnippet()
{
    Add("abc");
    Add("abd");
    Add("abc");
}
void Add(string s)
{
    if (list.Contains(s))
        Console.WriteLine("Exists :" + s);
    else
    {
        list.Add(s);
        Console.WriteLine(s);
    }
}
Will report that "abc" exists the second time.
Remember that you will want these to be case insensitive comparisions!
 
Share this answer
 
Comments
Аslam Iqbal 21-Sep-11 12:27pm    
Good answer. my 5
Abhinav S 21-Sep-11 12:51pm    
Nice. 5.

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