how to enable 2nd textbox as i enter data in first textbox.
i have two textbox txt1 and txt2. txt2 enable="false".
i want that as i enter any character in txt1 (focus still on txt1) txt2 enabled property should become false.
i am able to do this when i set my focus out of txt1. but nt able to do this as i enter the first input in the txt1.
Loading

Zoran HorvatRank #792 · 2.9K reputationPosted Aug 5, 2011, 12:53 AM EDT
Zoran
Zoran HorvatRank #792 · 2.9K reputationPosted Aug 4, 2011, 11:54 PM EDT
void txt1_TextChanged(object sender, EventArgs e)
{
txt2.Enabled = string.IsNullOrEmpty(txt1.Text);
}
This whill act upon every character entered in txt1. Whenever txt1 contains any non-empty text, txt2 will be disabled. As soon as you delete the last chracter from txt1, txt2 will become enabled.
Zoran
VulpesRank #55 · 29.2K reputationPosted Aug 5, 2011, 12:00 AM EDT
nishant ranjanRank #4,961 · 317 reputationPosted Aug 5, 2011, 12:09 AM EDT
nishant ranjanRank #4,961 · 317 reputationPosted Aug 5, 2011, 12:11 AM EDT
Zoran HorvatRank #792 · 2.9K reputationPosted Aug 5, 2011, 12:16 AM EDT
function DisableTxt2(txt1Text)
{
var txt2 = document.getElementById("txt2");
if (txt1Text.length == 0)
txt2.disabled = false;
else
txt2.disabled = true;
}
Then in the txt1 element definition:
Zoran
nishant ranjanRank #4,961 · 317 reputationPosted Aug 5, 2011, 12:40 AM EDT
Zoran HorvatRank #792 · 2.9K reputationPosted Aug 5, 2011, 12:44 AM EDT
function DisableTxt2(txt1Text)
{
var txt2 = document.getElementById("txt2");
if (txt1Text.length == 0)
txt2.disabled = true;
else
txt2.disabled = false;
}
Zoran
nishant ranjanRank #4,961 · 317 reputationPosted Aug 5, 2011, 12:46 AM EDT
nishant ranjanRank #4,961 · 317 reputationPosted Aug 5, 2011, 1:30 AM EDT
nishant ranjanRank #4,961 · 317 reputationPosted Aug 5, 2011, 1:31 AM EDT