How to set autofocus textbox using JavaScript

{0 Comments}

Following is the JavaScript code which will help you to set focus on text box, on every page loaded. Just keep in mind to change your text box id in get element id function. Except this all you have to add following script in your head or below the body tag. 

 Javascript |  copy code |? 
1
<script type="text/javascript">
2
    window.onload = function() { document.getElementById("TextBox1").focus();
3
    };
4
    </script>

Leave a Comment

Your email address will not be published.