EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Trigger a submit with Enter


Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html

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.


 <HTML><HEAD> 
  <SCRIPT LANGUAGE="JavaScript">
  function submit1() {
    document.PwdForm.pwd.focus();
    /*  don't submit yet */
    return false;
    }

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

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



Posted On: 10-Jul-1999

internet.commerce



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy