Enabling & Disabling Textbox web controls on client-side

I have two TextBox web controls and a button

if the user enters text into TextBox1, TextBox2 is disabled

if the user enters text into TextBox2, TextBox1 is disabled

after user enters text into TextBox1 and directly clicks the button

the text entered in TextBox1 is displayed in a label

same goes for when user enters text in TextBox2

Anyone know if this can be done using javascript?

Any suggestions would be appreciated.

thanks.

bebop
[524 byte] By [bebop1] at [2007-11-18 18:23:13]
# 1 Re: Enabling & Disabling Textbox web controls on client-side
Sure that is pretty simple. Start by setting uniqe ID attributes on the text boxes, so you can refer to them using the function document.getElementbyId('id'). Then declare some javascript functions in the header that maniplulates these text boxes. Set the onclick attribute on the buttons, to call these functions.

You can find all the javascript documentation you need here http://devedge.netscape.com/library/manuals/
The javascript core reference and guide, along with the Gecko DOM reference will probably be the most usefull for you.
khp at 2007-11-8 0:19:06 >
# 2 Re: Enabling & Disabling Textbox web controls on client-side
I'm using two textboxes and one button for a c# .NET app

code:

<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 248px; POSITION: absolute; TOP: 128px" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" style="Z-INDEX: 102; LEFT: 248px; POSITION: absolute; TOP: 168px" runat="server"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 248px; POSITION: absolute; TOP: 216px" runat="server" Text="Button"></asp:Button>
<asp:Label id="Label1" style="Z-INDEX: 104; LEFT: 472px; POSITION: absolute; TOP: 240px" runat="server">Label</asp:Label>
</form>

When user enters text into TextBox1, I would like TextBox2 to be disable so the user can't enter text into it

then when user clicks the button the text in TextBox1 is displayed in a label

and vice versa for entering text into TextBox2

bebop
bebop1 at 2007-11-8 0:20:13 >