Share this page 

Trigger a submit with Enter Tag(s): Varia

The trick is to use 2 forms. The first one contains all the fields except the last one. The second form contains the last field and in the submit function, we read the values from the first form and put them in hidden fields defined in the second form. After validation, the submit function returns true or false to submit or not.
 function submit1() {
   /*  don't submit yet */
   return false;

 function submit2() {
   document.PwdForm.username.value =
   /* perform any validation here */
   /* and submit */
   return true;
 <FORM NAME="LoginForm" onSubmit="return submit1()">
 <P>User Name: <INPUT NAME="username" TYPE="TEXT">

 <FORM NAME="PwdForm" onSubmit="return submit2()">
 <INPUT NAME="username" TYPE="HIDDEN">
 <P>Password: <INPUT NAME="pwd" TYPE="PASSWORD">