Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

cursor defaults to inputtext box  RSS feed

 
naveen gupta
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when the user is in application login screen how can i make the cursor default to inputtext box to enter username
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what you actually are asking is how to cause the input focus to be set to the username textbox control.

You cannot do that using server-side code, because it's a client-side action.

However you can setup an onload javascript event handler on your web page (login form) that can execute JavaScript code that will give the focus to the username control.
 
naveen gupta
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was able to do for login screen using below code

<body onload="document.login_form.j_username.focus()">

-------------------------

But i want same functionality in my application for one of the field

And since i am using Facelets with JSF/RichFaces

my body tag is base.xhtml page and my actual page is search.xhtml

so in this case, how can i do
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!