我在页面上加入了两个<input>
分别为
<input id="Text1" type="text" />
<input id="Text2" type="text" />
现在我想在javascript中读取这两个值,来做比较,看他们是否一样。
请问:为什么这样写,不能实现
<script>
if(document.getElementById("Text1").value==document.getElementById("Text2").value)
{ return true;}
else
{ return false;}
</script>是不是document.getElementById("Text1").value和document.getElementById("Text2").value这两个值都是string类型的,不能这样比较。
如果是的话,有什么方法可以实现。我要的就是比较那两个文本框的内容是否一样。
分别为
<input id="Text1" type="text" />
<input id="Text2" type="text" />
现在我想在javascript中读取这两个值,来做比较,看他们是否一样。
请问:为什么这样写,不能实现
<script>
if(document.getElementById("Text1").value==document.getElementById("Text2").value)
{ return true;}
else
{ return false;}
</script>是不是document.getElementById("Text1").value和document.getElementById("Text2").value这两个值都是string类型的,不能这样比较。
如果是的话,有什么方法可以实现。我要的就是比较那两个文本框的内容是否一样。
解决方案 »
- html 控件
- 各位老大:我在DataGrid里面添加删除,删除后页面不要跳出,怎么办?
- 在GRIDVIEW里,如何把鼠标放在一行上,鼠标旁边的小字显示的是数据库中的内容?
- 删除数据出错
- 工作流引擎(workflow engine)的项目,请大家给点建议?
- DataList编辑项中DropDownList控件的使用?
- 编译时出现这个错误:读取密钥文件“..\..\myKeyPair.snk”时出错,如何解决?
- GridView的有关合计汇总问题
- 如何才能在server端接收到从客户端传来的参数?。不够再加分
- 如何做到只打印panel里的内容?谢谢
- gridview中能够实现单击HyperLinkField按钮后,根据情况判断是否跳转?
- 我在自己机器上运行的出这样的错,放在其他机器上正常,高人指点下哈
function bJ()
{
if(document.getElementById("Text1").value==document.getElementById("Text2").value)
{
alert("相同");
return true;}
else
{
alert("不相同");
return false;}
}
</script>
上面这句最后的")"换成")"
下面这样写
{
alert("相等");
}
else
{
alert("不相等");
}
{
alert("相同")';
}
else
{
laert('不同');
}
如果不行,你就这样
if(document.getElementById("Text1").value==document.getElementById("Text2").value)
{ return true;}
else
{ return false;}那个value 改成 Value 看看