Javascript Form How to - Set the focus to the password box








Question

We would like to know how to set the focus to the password box.

Answer


<!--from ww w . j  a v  a  2 s .c o  m-->
<html>
<body>
    <form name="form1">
        <input type="PASSWORD" Name="pass" size=10>
        <br>
        <input type="BUTTON" value="Show Password" onClick=document.form1.pass.focus()>
    </form>
</body>
</html>

The code above is rendered as follows: