[thelist] Form Submittal on Enter

Ken Kogler ken.kogler at curf.edu
Mon Jan 28 12:14:01 CST 2002


Yup. Get rid of <input type="submit"> and replace it with <input
type="button" value="Submit" onClick="doSomething();">

Here's the JavaScript function I've used:

<code>
<script LANGUAGE="Javascript">
function submitsthis() {
  document.forms[0].submit();
  }
</script>
</code>

Note that this will submit the first <form> tag on the page. So if in
your page you have:
<form>
</form>
<form>
This is the one I want to submit
</form>

You're going to need to change that line to
"document.forms[1].submit();"

E-mail me offlist if you have any problems related to this script.

-Ken Kogler


-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org] On Behalf Of josh
Sent: Monday, January 28, 2002 10:09 AM
To: thelist at lists.evolt.org
Subject: [thelist] Form Submittal on Enter


I have noticed that IE4.0 (and perhaps others) will submit a form when
the
user hits the "Enter" key even when there is more than one field in the
form.

Do any of you have Javascript solutions to prevent the submission of the
form unless the Submit button was pressed?

Thanks,
Josh
--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list