General discussion

Locked

Set focus on form submit botton

By lynnmoon ·
I have an html form that collects a user name and password. When I enter the user name and password, I would like to just hit enter to send the form as opposed to tabing to the submit button. I thought that this just happened automatically, but itdoes not happen on my form. What do I do?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Set focus on form submit botton

by DKlippert In reply to Set focus on form submit ...
Collapse -

Set focus on form submit botton

by lynnmoon In reply to Set focus on form submit ...

The question was auto-closed by TechRepublic

Collapse -

Set focus on form submit botton

by Jay Eckles In reply to Set focus on form submit ...

This has to be implemented by the browser that the user is using. In IE (only), the following script will submit the form when the user presses ENTER:

<SCRIPT event=onkeydown for=document language=javascript>
if( window.event.keyCode = 13 ){ document.formname.submit() ;
}
</SCRIPT>

...well, at least I think it will do that - I haven't bothered to test it. Also, know that this will submit the form if the user hits ENTER anywhere on the page. You might try changing the "for" attribute of the script to "document.formname.inputname".

Good luck.

Jay

Collapse -

Set focus on form submit botton

by lynnmoon In reply to Set focus on form submit ...

The question was auto-closed by TechRepublic

Collapse -

Set focus on form submit botton

by lynnmoon In reply to Set focus on form submit ...

This question was auto closed due to inactivity

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums