I have a text box control and i have coded its "onblur" event t a Javascript function. I want this javascript function to make visible a checkbox based on comaprison between the textbox being blurred and a hidden textbox on the same page. The javascript is not working. Please help. Here is what I have coded in ASP.NET 2.0 page.
Thanks
Bhushan (<email snipped>)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Check Box Check</title>
<script language="javas cript" type="text/javascript">
function CheckBoxCheck()
{
var t1 = document.getEle mentById("<%=tx t1.ClientId %>");
var t2 = document.getEle mentById("<%=tx t2.ClientId %>");
var chk = document.getEle mentById("<%=ch k1.ClientId %>");
var t1Value = 0;
var t2Value = 0;
if ( ( t1.value == "" ) || ( t1.value == null ) || (t1.value == undefined))
{};
else
{
alert('reached 1');
if ( ( t2.value == "" ) || ( t2.value == null ) || (t2.value == undefined))
{};
else
{
t1value = t1.value;
t2value = t2.value;
if (t1value == t2value)
{chk.visible = false;
alert('reached 3')};
else
{chk.visible = true;
alert('reached 4')};
};
};
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt1" runat="server" onblur="CheckBo xCheck()"></asp:TextBox>
<asp:CheckBox ID="chk1" runat="server" Visible="False" />
<asp:TextBox ID="txt2" runat="server" Visible="true"> 555</asp:TextBox><br />
<asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
</form>
</body>
</html>
Thanks
Bhushan (<email snipped>)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Check Box Check</title>
<script language="javas cript" type="text/javascript">
function CheckBoxCheck()
{
var t1 = document.getEle mentById("<%=tx t1.ClientId %>");
var t2 = document.getEle mentById("<%=tx t2.ClientId %>");
var chk = document.getEle mentById("<%=ch k1.ClientId %>");
var t1Value = 0;
var t2Value = 0;
if ( ( t1.value == "" ) || ( t1.value == null ) || (t1.value == undefined))
{};
else
{
alert('reached 1');
if ( ( t2.value == "" ) || ( t2.value == null ) || (t2.value == undefined))
{};
else
{
t1value = t1.value;
t2value = t2.value;
if (t1value == t2value)
{chk.visible = false;
alert('reached 3')};
else
{chk.visible = true;
alert('reached 4')};
};
};
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt1" runat="server" onblur="CheckBo xCheck()"></asp:TextBox>
<asp:CheckBox ID="chk1" runat="server" Visible="False" />
<asp:TextBox ID="txt2" runat="server" Visible="true"> 555</asp:TextBox><br />
<asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
</form>
</body>
</html>
Comment