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 HorvatPosted Aug 5, 2011, 4:53 AM
Zoran
nishant ranjanPosted Aug 5, 2011, 5:31 AM
nishant ranjanPosted Aug 5, 2011, 5:30 AM
nishant ranjanPosted Aug 5, 2011, 4:46 AM
Zoran HorvatPosted Aug 5, 2011, 4:44 AM
function DisableTxt2(txt1Text)
{
var txt2 = document.getElementById("txt2");
if (txt1Text.length == 0)
txt2.disabled = true;
else
txt2.disabled = false;
}
Zoran
nishant ranjanPosted Aug 5, 2011, 4:40 AM
Zoran HorvatPosted Aug 5, 2011, 4:16 AM
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 ranjanPosted Aug 5, 2011, 4:11 AM
nishant ranjanPosted Aug 5, 2011, 4:09 AM
VulpesPosted Aug 5, 2011, 4:00 AM
Zoran HorvatPosted Aug 5, 2011, 3:54 AM
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