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

Q27 How can I submit a form which has more than one text field by just pressing enter?

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

This is achieved with the following code:

<script language="JavaScript"><!--
function submit1() {
    document.passwordForm.passwordField.focus();
    return false;
}

function submit2() {
    document.passwordForm.useridField.value = document.useridForm.useridField.value;
    /* perform any validation here */
    return true;
}
//--></script>

<form name="useridForm" onSubmit="return submit1()">
<p>Userid: <input name="useridField" type="text">
</form>

<form name="passwordForm" onSubmit="return submit2()">
<input name="useridField" type="hidden">
<p>Password: <input name="passwordField" type="password">
</form>

Feedback on 'Q27 How can I submit a form which has more than one text field by just pressing enter?'

©2018 Martin Webb