[thelist] dHTML Form Elements && tip re: Disabling the <enter> key to submit a form.

Tab Alleman talleman at autobex.com
Fri Dec 1 12:47:40 CST 2000


Ok, so if a non-js user submits a form that has onsubmit() validation, the
validation would just get ignored and the form would submit normally, right?
Well, that wouldn't solve the original question of how to disable the
<enter> key for form submission, so I guess the consensus is that you can't,
without JavaScript.

For purposes of answering that specific question, I like my solution better
than Jeff's, because Jeff's will pop up some alert box telling the user they
didn't fill out some field before they (accidentally?) hit <enter>, and mine
will simply ignore the <enter> key altogether.  But I agree that caution
should be exercised before deciding to use my method, as it may do more harm
than good in some cases.

And finally, I'm not saying that you should always use functions with
submit() to handle form submissions, or even that it's a good habit to get
into.  I'm just saying you shouldn't always rule it out either...sometimes
it really can be exactly what you need.

(jeez, see if I ever try to leave a tip around here again...)  ;)

Tab


Tab,

> or is onsubmit() something that will get seamlessly ignored by
> non-js browsers?

	By definition, no event handler or function will work without
client-side scripting enabled. But as you and jeff agreed, working in a
controlled environment such as an Intranet (assuming that desktop
configurations are locked down so that users can't independently turn off
scripting) makes moot many of the concerns over submitting a form via script
rather than via built-in form-handling capabilities. However, as one who
does work within a controlled Intranet environment, I would still recommend
relying on the browser's built-in form-handling capabilities rather than on
the submit() method if for no other reason than that it is a good discipline
for when you do code for a less-controlled environment.

James Aylard

---------------------------------------
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