Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q682 Is it possible to cause a multi-field form to be submitted when the user hits the enter key no matter which field on the form the cursor is in?

You are here: irt.org | FAQ | JavaScript | Form | 7.1 | Q682 [ previous next ]

Try:

<SCRIPT LANGUAGE="JavaScript"><!--
function submit1() {
    document.useridForm.passwordField.value = document.passwordForm.passwordField.value;
}

function submit2() {
    document.passwordForm.useridField.value = document.useridForm.useridField.value;
}
//--></SCRIPT>

<FORM NAME="useridForm" onSubmit="submit1()">
<P>Userid: <INPUT NAME="useridField" TYPE="TEXT">
<INPUT NAME="passwordField" TYPE="HIDDEN">

<SCRIPT LANGUAGE="JavaScript"><!--
document.write('<\/FORM><FORM NAME="passwordForm" onSubmit="submit2()">')
//--></SCRIPT>

<INPUT NAME="useridField" TYPE="HIDDEN">
<P>Password: <INPUT NAME="passwordField" TYPE="PASSWORD">

<P><INPUT TYPE="SUBMIT">
</FORM>

Feedback on 'Q682 Is it possible to cause a multi-field form to be submitted when the user hits the enter key no matter which field on the form the cursor is in?'

©2018 Martin Webb