Forum Moderators: open
Is there a way to globally set and keep the focus on a submit button whilst filling out a form? We have a form that seems to default to the first button on the page, and we would rather it focused on the actual ‘Search’ (submit button) which is further down the page.
An alternative would be to remove focus from the buttons altogether, and rather than edit each button or element, we would prefer to have a global way of doing this.
Many thanks in advance,
-George
<form onkeypress="keyPressed(this,event)">
...function keyPressed(form,event)
{
event = event¦¦window.event
var key = event.which¦¦event.keyCode
if(key==13)
form.submit() // or whatever
}
This works for IE & NS. Only submitting when focus is somewhere in the form. It could be changed to always submit.
Have a read of this: [ppeph.gla.ac.uk ]
Firstly thanks for taking the time out to reply.
This is the weird thing, even though the user/client makes their way through the form filling out each of the input fields the focus seems to remain on a submit button at the same time :( I don't know if this issue is directly related to JSP/Tiles or not, but like you say the focus should be on the input element that the user is dealing with.
The application only needs to work in IE therefore we are only testing in IE.
-George
-George
Not that I see an issue with this, but the project leader refuses to have more JavaScript contained within the JSP's, we would have to attach an event handler to each of the normal buttons calling on the form submittal process.
It's good to hear everyone’s thoughts on this as I can raise them tomorrow at work with options available to use.
-George