Text in textbox enables button.

H

hledman

Hello beginner here.
I've been researching for awhile to find a way to enable a button when
text is entered into a textbox (client side). I working with asp.net
2.0 C#. I've been trying to figure this out through javascript or
someone told me to research Page.RegisterClientScriptBlock Method, but
I can't seem to figure this out. Any help will be appreciated.

Thanks
 
V

Vlad

Hey.

in your html:
<script>
function blah(textbox,button)
{
button.disabled = textbox.value.length == 0;
}
</script>

in your C# (in page load handler or wherever):

....
this.txtBox.Attributes["onkeyup"] =
string.Format("blah(this,getElementByID('{0}'));",this.btnSubmitOrWhateverItsNameIs.ClientID);
....

Hope this helps.
Kikoz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top