比较两个文本框,不要在两个文本框中输入相同的值 [英] Compare two textboxes, donot enter same value in both textboxes

查看:126
本文介绍了比较两个文本框,不要在两个文本框中输入相同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,您好!



我想比较并验证两个文本框

========== ==================================



在我的网页上我有两个文本框,用户不能在两个文本框中输入相同的值。如果他在两个文本框中输入相同的值。它必须显示错误。



注意:两个文本框中的值必须不同。



请帮助,提前谢谢

Hello my dear friends,

I want to compare and validate two textboxes
============================================

on my webpage i have two textboxes, user must not enter same values in both textboxes. if he enter same values in both textboxes. it must show error.

Note : Values must be different in two textboxes.

Please help, thanks in advance

推荐答案

aspnetvalidationcontrols.html [ ^ ]



comparevalidator.asp [ ^ ]



http://msdn.microsoft.com/en-us/library/db330ayw(v=vs.71).aspx [ ^ ]



使用CompareValidator ..请看上面的链接..希望它能帮助..
aspnetvalidationcontrols.html[^]

comparevalidator.asp[^]

http://msdn.microsoft.com/en-us/library/db330ayw(v=vs.71).aspx[^]

Use CompareValidator..see the links above..hope it will help..


protected void button1_Click(object sender, EventArgs e)
       {
           if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim() == "")
               lblMessage.Text = "One or more input field is empty,Please enter values";

           if (TextBox1.Text.Trim() == TextBox2.Text.Trim())
               lblMessage.Text = "Please enter different values";

       }


这里是您要求的确切解决方案。



这将完全适合你。



http://www.w3schools.com/aspnet/showaspx.asp?filename=demo_comparevalidator2 [ ^ ]
Here the exact solution you are asking for.

This will work exactly for you.

http://www.w3schools.com/aspnet/showaspx.asp?filename=demo_comparevalidator2[^]


这篇关于比较两个文本框,不要在两个文本框中输入相同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆