Unfocus/focus a textbox - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text


Unfocus/focus a textbox

Demo Code

ResultView the demo in separate window

       Name: /*w ww .  j  ava  2s . c o  m*/
      <input type="text" id="myText"> 
      <p>Click the button to unfocus the text field.</p> 
      <button onclick="myFunction()">Unfocus input</button> 

function myFunction() {
    document.getElementById("myText").disabled = true;
    document.getElementById("myText").disabled = false;


Related Tutorials