Wednesday, 21 January 2015

how to enable or disable a button on keypress event of a textbox using javascript ?

<asp:TextBox  runat="server"  id="TxtDemo" value="" onkeydown="btn_Enable()"/> 

<asp:Button runat="server"  id="btnDemo">Some test</button> 




Javascript:
     window.onload = function()
 { 

    document.getElementById('btnDemo').disabled = true;  

} 

function btn_Enable() { 

     var EN=document.getElementById(TxtDemo).value; 

     if(EN=='') { 

         document.getElementById('btnDemo').disabled=true; 

     }
 else
 { 

         document.getElementById('btnDemo').disabled=false; 

     } 

} 

No comments:

Post a Comment