Javascript enable/disable button based on text in textboxesPCPooja Chowdhury10yAsked Feb 25, 2016, 1:50 AM EST10 answersShareLinkedInXCopy linkSaveCodeCopy but its throws an error the error is:The Controls collection cannot be modified because the control contains code blocks
Javascript enable/disable button based on text in textboxesPCPooja Chowdhury10yAsked Feb 25, 2016, 1:50 AM EST10 answersShareLinkedInXCopy linkSaveCodeCopy but its throws an error the error is:The Controls collection cannot be modified because the control contains code blocks
Shubham KumarRank #621 · 3.8K reputation10y agoPosted Feb 25, 2016, 1:58 AM EST0 Hi,It's of because there is no any OnKeyup event in asp textbox try to use OnBlur event 0
PCPooja ChowdhuryRank #3,615 · 403 reputation10y agoPosted Feb 25, 2016, 2:08 AM EST0onblur event was not working.0
Shubham KumarRank #621 · 3.8K reputation10y agoPosted Feb 25, 2016, 2:25 AM EST0try this or if you want on keyup event so do like this on page load event (codebehind) page_load{ this.txtId.Attributes.add("onkeyup","javascript:SetButtonStatus();"); } 0
Amit Kumar SinghRank #562 · 4.3K reputation10y agoPosted Feb 25, 2016, 2:49 AM EST0 hey,try this function SetButtonStatus(sender, target) { var first = document.getElementById('<%=txtfirst.ClientID %>'); var second = document.getElementById('<%=txtText.ClientID %>'); if ((sender.value.length >= 1 && first.value.length >= 1) && (sender.value.length >= 1 && second.value.length >= 1)) { document.getElementById(target).disabled = false; } else { document.getElementById(target).disabled = true; } } 0
PCPooja ChowdhuryRank #3,615 · 403 reputation10y agoPosted Feb 25, 2016, 3:10 AM EST0Hi Amit, i already tried this same code.it was not working0
Amit Kumar SinghRank #562 · 4.3K reputation10y agoPosted Feb 25, 2016, 3:13 AM EST0its working ......run code which i have provided0
PCPooja ChowdhuryRank #3,615 · 403 reputation10y agoPosted Feb 25, 2016, 7:34 PM EST0it throws an error the error is: Actually it contains tabcontainer... The Controls collection cannot be modified because the control contains code blocks 0
Amit Kumar SinghRank #562 · 4.3K reputation10y agoPosted Feb 25, 2016, 7:44 PM EST0 Try this, protected void Page_Load(object sender, EventArgs e) { Page.Header.DataBind(); } 0
PCPooja ChowdhuryRank #3,615 · 403 reputation10y agoPosted Feb 25, 2016, 8:12 PM EST0no error... but when i put the value in the textbox. the button doesn't enabled. can you please tried it in tabcontainer. 0Amit Kumar SinghRank #562 · 4.3K reputation10y agoPosted Feb 25, 2016, 8:15 PM EST0Enter text in both textbox....it will enabled0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit Kumar SinghRank #562 · 4.3K reputation10y agoPosted Feb 25, 2016, 8:15 PM EST0Enter text in both textbox....it will enabled0
Shubham KumarRank #621 · 3.8K reputationPosted Feb 25, 2016, 1:58 AM EST
Pooja ChowdhuryRank #3,615 · 403 reputationPosted Feb 25, 2016, 2:08 AM EST
Shubham KumarRank #621 · 3.8K reputationPosted Feb 25, 2016, 2:25 AM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 25, 2016, 2:49 AM EST
hey,try this
Pooja ChowdhuryRank #3,615 · 403 reputationPosted Feb 25, 2016, 3:10 AM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 25, 2016, 3:13 AM EST
Pooja ChowdhuryRank #3,615 · 403 reputationPosted Feb 25, 2016, 7:34 PM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 25, 2016, 7:44 PM EST
{
Page.Header.DataBind();
}
Pooja ChowdhuryRank #3,615 · 403 reputationPosted Feb 25, 2016, 8:12 PM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 25, 2016, 8:15 PM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts