You're using document.getElementById("username") when the ID is actually textinput5 . document.getElementById("username").focus(); should be ...
stackoverflow.com