文本框验证,以避免重复输入 [英] TextBox Validation for avoiding redundant entry
问题描述
我有5个文本框,用于输入emailId,
我需要对每个文本框和
进行电子邮件验证
我应该验证文本框,以使我在1st或任何其他文本框中输入的mailId不应在任何其他文本框中重复.
例如:
TextBox1:-abc@aa.com
TextBox2:-abc@bb.com
TextBox3:-abc@cc.com
TextBox4:-abc@dd.com
TextBox5:-abc@aa.com
这里的Textbox1& Textbox5具有相同的ID,但不应相同.
我如何在Asp.net中进行验证.
问候,
yuva
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
推荐答案
取决于您在哪里做.
如果验证是在服务器端:
Depends on where you are doing it.
If the validation is server side:
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);
}
}
将报告"abc"第二次存在.
请记住,您将希望它们是不区分大小写的比较!
Will report that "abc" exists the second time.
Remember that you will want these to be case insensitive comparisions!
这篇关于文本框验证,以避免重复输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!